mlanett-redis-lock 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/redis-lock.rb +3 -1
- data/lib/redis-lock/version.rb +1 -1
- data/redis-lock.gemspec +1 -1
- metadata +6 -2
data/README.md
CHANGED
@@ -62,6 +62,10 @@ You need to handle race conditions while cleaning the stale lock and acquiring a
|
|
62
62
|
The code which cleans the stale lock may not be able to assume it gets the new one.
|
63
63
|
The code which cleans the stale lock must not interfere with a different owner acquiring the lock.
|
64
64
|
|
65
|
+
## Contributors
|
66
|
+
|
67
|
+
Alexander Lang (langalex), Jonathan Hyman (jonhyman), Jamie Cobbett (jamiecobbett), and Ravil Bayramgalin (brainopia) have contributed to Redis Lock.
|
68
|
+
|
65
69
|
## Contributing
|
66
70
|
|
67
71
|
1. Fork it
|
data/lib/redis-lock.rb
CHANGED
@@ -17,6 +17,8 @@ class Redis
|
|
17
17
|
attr_accessor :life # how long we expect to keep this lock locked
|
18
18
|
attr_accessor :logger
|
19
19
|
|
20
|
+
HOST = `hostname`.strip
|
21
|
+
|
20
22
|
# @param redis is a Redis instance
|
21
23
|
# @param key is a unique string identifying the object to lock, e.g. "user-1"
|
22
24
|
# @param options[:life] may be set, but defaults to 1 minute
|
@@ -27,7 +29,7 @@ class Redis
|
|
27
29
|
@redis = redis
|
28
30
|
@key = key
|
29
31
|
@okey = "lock:owner:#{key}"
|
30
|
-
@oval = options[:owner] || "#{
|
32
|
+
@oval = options[:owner] || "#{HOST}:#{Process.pid}"
|
31
33
|
@xkey = "lock:expire:#{key}"
|
32
34
|
@life = options[:life] || 60
|
33
35
|
@sleep_in_ms = options[:sleep] || 125
|
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"]
|
5
|
+
gem.authors = ["Mark Lanett", "Ravil Bayramgalin", "Jamie Cobbett", "Jonathan Hyman", "Alexander Lang"]
|
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}
|
metadata
CHANGED
@@ -1,15 +1,19 @@
|
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Lanett
|
9
|
+
- Ravil Bayramgalin
|
10
|
+
- Jamie Cobbett
|
11
|
+
- Jonathan Hyman
|
12
|
+
- Alexander Lang
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
date: 2013-
|
16
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
13
17
|
dependencies:
|
14
18
|
- !ruby/object:Gem::Dependency
|
15
19
|
name: redis
|