redis_support 0.0.17 → 0.0.18
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_support/locks.rb +4 -0
- data/test/test_redis_support.rb +14 -0
- metadata +6 -6
data/lib/redis_support/locks.rb
CHANGED
@@ -104,6 +104,10 @@ module RedisSupport
|
|
104
104
|
def is_redis_locked?( locked_key )
|
105
105
|
locked_until(locked_key) > Time.now.to_i
|
106
106
|
end
|
107
|
+
|
108
|
+
def is_redis_fulfilling_locked?( locked_key )
|
109
|
+
redis.get( locked_key ).to_i > Time.now.to_i
|
110
|
+
end
|
107
111
|
|
108
112
|
def locked_until(locked_key)
|
109
113
|
redis.get( lock_key(locked_key) ).to_i
|
data/test/test_redis_support.rb
CHANGED
@@ -113,6 +113,20 @@ context "Redis Support" do
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
+
test "is_redis_fulfilling_locked? works as expected " do
|
117
|
+
class Fulfill
|
118
|
+
include RedisSupport
|
119
|
+
end
|
120
|
+
@fulfill = Fulfill.new
|
121
|
+
@fulfill.redis.set("example:true:key", (Time.now + 300).to_i)
|
122
|
+
assert_equal (Fulfill.is_redis_fulfilling_locked?("example:true:key"), true)
|
123
|
+
|
124
|
+
@fulfill.redis.set("example:false:key", (Time.now - 300).to_i)
|
125
|
+
assert_equal (Fulfill.is_redis_fulfilling_locked?("example:false:key"), false)
|
126
|
+
|
127
|
+
assert_equal (Fulfill.is_redis_fulfilling_locked?("example:doesnt_exsist:key"), false)
|
128
|
+
end
|
129
|
+
|
116
130
|
test "redis_lock_nonblock performs as expected" do
|
117
131
|
class Zoo
|
118
132
|
include RedisSupport
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 59
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 18
|
10
|
+
version: 0.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian P O'Rourke
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2012-02-08 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
requirements: []
|
95
95
|
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 1.4.2
|
98
98
|
signing_key:
|
99
99
|
specification_version: 3
|
100
100
|
summary: A Redis Support module
|