redis_ha 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/redis_ha/connection.rb +7 -6
- data/lib/redis_ha/semaphore.rb +1 -1
- data/redis_ha.gemspec +1 -1
- metadata +3 -3
data/lib/redis_ha/connection.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class RedisHA::Connection < Thread
|
2
2
|
|
3
|
-
POLL_INTERVAL = 0.
|
3
|
+
POLL_INTERVAL = 0.01
|
4
4
|
|
5
5
|
attr_accessor :status, :buffer
|
6
6
|
|
@@ -12,8 +12,9 @@ class RedisHA::Connection < Thread
|
|
12
12
|
@redis_opts = redis_opts
|
13
13
|
|
14
14
|
@queue = Array.new
|
15
|
+
@queue_lock = Mutex.new
|
15
16
|
@buffer = Array.new
|
16
|
-
@
|
17
|
+
@buffer_lock = Mutex.new
|
17
18
|
|
18
19
|
super do
|
19
20
|
run
|
@@ -21,13 +22,13 @@ class RedisHA::Connection < Thread
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def next
|
24
|
-
@
|
25
|
+
@buffer_lock.synchronize do
|
25
26
|
@buffer.shift
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
30
|
def <<(msg)
|
30
|
-
@
|
31
|
+
@buffer_lock.synchronize do
|
31
32
|
@queue << msg
|
32
33
|
end
|
33
34
|
end
|
@@ -38,7 +39,7 @@ private
|
|
38
39
|
while job = pop
|
39
40
|
semaphore, *msg = job
|
40
41
|
|
41
|
-
@
|
42
|
+
@buffer_lock.synchronize do
|
42
43
|
@buffer << send(*msg)
|
43
44
|
end
|
44
45
|
|
@@ -49,7 +50,7 @@ private
|
|
49
50
|
def pop
|
50
51
|
loop do
|
51
52
|
sleep(POLL_INTERVAL) while @queue.size < 1
|
52
|
-
@
|
53
|
+
@queue_lock.synchronize do
|
53
54
|
job = @queue.shift
|
54
55
|
return job if job
|
55
56
|
end
|
data/lib/redis_ha/semaphore.rb
CHANGED
data/redis_ha.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_ha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-11-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &9331680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9331680
|
25
25
|
description: Three basic CRDTs (set, hashmap and counter) for redis. Also includes
|
26
26
|
a ConnectionPool that allows you to run concurrent redis commands on multiple connections
|
27
27
|
w/o using eventmachine/em-hiredis.
|