mlanett-redis-lock 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/redis-lock.rb +4 -1
- data/lib/redis-lock/version.rb +1 -1
- data/redis-lock.gemspec +1 -1
- data/spec/redis_lock_spec.rb +9 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 148ebe29b3ebd72bd6cc37ab0e34b471326c8076
|
4
|
+
data.tar.gz: 2e6110d8ba371f5ad6d7ee40ae5e35ad1b555c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52b8e7beac0570d9bd348cf0ec8f90a5f1dc3ff5fa8ebde0e5e44a7d04f4dde99614e1e799d695bc5184a314a3bf39c096b3cd6c09bf7c56b9f784e30b712a79
|
7
|
+
data.tar.gz: 9fa50ba005240a11dee08225481842012c52a1d2b25f0bcfbd0f872509f46d55a72b4e36646e62214163891ec86caa16a309cd3d150b3fd600ff44292022c4f8
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ The code which cleans the stale lock must not interfere with a different owner a
|
|
67
67
|
|
68
68
|
## Contributors
|
69
69
|
|
70
|
-
Alexander Lang (langalex), Jonathan Hyman (jonhyman), Jamie Cobbett (jamiecobbett),
|
70
|
+
Alexander Lang (langalex), Jonathan Hyman (jonhyman), Jamie Cobbett (jamiecobbett), Ravil Bayramgalin (brainopia), and Tom Mornini (tmornini) have contributed to Redis Lock.
|
71
71
|
|
72
72
|
## Contributing
|
73
73
|
|
data/lib/redis-lock.rb
CHANGED
@@ -228,7 +228,10 @@ class Redis
|
|
228
228
|
# @param options[:acquire] defaults to 10 seconds and can be used to determine how long to wait for a lock.
|
229
229
|
def lock( key, options = {}, &block )
|
230
230
|
acquire = options.delete(:acquire) || 10
|
231
|
-
|
231
|
+
|
232
|
+
lock = Redis::Lock.new self, key, options
|
233
|
+
|
234
|
+
block_given? ? lock.lock(acquire, &block) : lock
|
232
235
|
end
|
233
236
|
|
234
237
|
def unlock( key )
|
data/lib/redis-lock/version.rb
CHANGED
data/redis-lock.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require File.expand_path('../lib/redis-lock/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Mark Lanett", "Ravil Bayramgalin", "Jamie Cobbett", "Jonathan Hyman", "Alexander Lang"]
|
5
|
+
gem.authors = ["Mark Lanett", "Ravil Bayramgalin", "Jamie Cobbett", "Jonathan Hyman", "Alexander Lang", "Tom Mornini"]
|
6
6
|
gem.email = ["mark.lanett@gmail.com"]
|
7
7
|
gem.description = %q{Pessimistic locking using Redis}
|
8
8
|
gem.summary = %q{Pessimistic locking using Redis}
|
data/spec/redis_lock_spec.rb
CHANGED
@@ -136,10 +136,17 @@ describe Redis::Lock, redis: true do
|
|
136
136
|
# We leave [ present, present ] to be unspecified.
|
137
137
|
end
|
138
138
|
|
139
|
-
example "How to get a lock using the helper
|
139
|
+
example "How to get a lock using the helper when passing a block" do
|
140
140
|
redis.lock "mykey", life: 10, acquire: 1 do |lock|
|
141
141
|
lock.extend_life 10
|
142
|
-
|
142
|
+
:return_value_of_block
|
143
|
+
end.should eql(:return_value_of_block)
|
144
|
+
end
|
145
|
+
|
146
|
+
example "How to get a lock using the helper when not passing a block" do
|
147
|
+
lock = redis.lock "mykey", life: 10, acquire: 1
|
148
|
+
lock.should be_an_instance_of(Redis::Lock)
|
149
|
+
lock.unlock
|
143
150
|
end
|
144
151
|
|
145
152
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mlanett-redis-lock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Lanett
|
@@ -9,10 +9,11 @@ authors:
|
|
9
9
|
- Jamie Cobbett
|
10
10
|
- Jonathan Hyman
|
11
11
|
- Alexander Lang
|
12
|
+
- Tom Mornini
|
12
13
|
autorequire:
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
|
-
date:
|
16
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
16
17
|
dependencies:
|
17
18
|
- !ruby/object:Gem::Dependency
|
18
19
|
name: redis
|
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
version: '0'
|
75
76
|
requirements: []
|
76
77
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.4.5.1
|
78
79
|
signing_key:
|
79
80
|
specification_version: 4
|
80
81
|
summary: Pessimistic locking using Redis
|