redis-semaphore 0.1.7 → 0.2.0
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/README.md +6 -1
- data/lib/redis/semaphore.rb +7 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -174,8 +174,12 @@ Testing
|
|
174
174
|
Changelog
|
175
175
|
---------
|
176
176
|
|
177
|
+
###0.2.0 June 2, 2013
|
178
|
+
- Use Redis TIME command for lock timeouts (thanks dubdronic!).
|
179
|
+
- Version increase because of new dependency on Redis 2.6+
|
180
|
+
|
177
181
|
###0.1.7 April 18, 2013
|
178
|
-
- Fix bug where ```
|
182
|
+
- Fix bug where ```release_stale_locks!``` was not public (thanks scomma!).
|
179
183
|
|
180
184
|
###0.1.6 March 31, 2013
|
181
185
|
- Add non-ownership of tokens
|
@@ -213,3 +217,4 @@ Thanks to these awesome peeps for their contributions:
|
|
213
217
|
- [Tim Galeckas](https://github.com/timgaleckas)
|
214
218
|
- [Ruurd Pels](https://github.com/ruurd)
|
215
219
|
- [Prathan Thananart](https://github.com/scomma)
|
220
|
+
- [dubdromic](https://github.com/dubdromic)
|
data/lib/redis/semaphore.rb
CHANGED
@@ -52,7 +52,7 @@ class Redis
|
|
52
52
|
|
53
53
|
current_token = token_pair[1]
|
54
54
|
@tokens.push(current_token)
|
55
|
-
@redis.hset(grabbed_key, current_token,
|
55
|
+
@redis.hset(grabbed_key, current_token, current_time.to_f)
|
56
56
|
|
57
57
|
if block_given?
|
58
58
|
begin
|
@@ -117,7 +117,7 @@ class Redis
|
|
117
117
|
@redis.hgetall(grabbed_key).each do |token, locked_at|
|
118
118
|
timed_out_at = locked_at.to_f + @stale_client_timeout
|
119
119
|
|
120
|
-
if timed_out_at <
|
120
|
+
if timed_out_at < current_time.to_f
|
121
121
|
signal(token)
|
122
122
|
end
|
123
123
|
end
|
@@ -182,5 +182,10 @@ class Redis
|
|
182
182
|
def grabbed_key
|
183
183
|
@grabbed_key ||= namespaced_key('GRABBED')
|
184
184
|
end
|
185
|
+
|
186
|
+
def current_time
|
187
|
+
instant = @redis.time
|
188
|
+
Time.at(instant[0], instant[1])
|
189
|
+
end
|
185
190
|
end
|
186
191
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-semaphore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|