robust-redis-lock 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e332c20c041bdebe126c785004c3443a72e97a5f
4
+ data.tar.gz: 913353411073f33d4c9603c95bf5e222d13ce532
5
+ SHA512:
6
+ metadata.gz: 45ccdd616b790ccd941a8ee7ea7da08ae91da73778b4ff9a3fe20d7b0542c3fa3ae2b02d487f748c94abb10ef1ea239ddfa19828be9dcac5aa6b91255b571797
7
+ data.tar.gz: 89e2496e59d7801ea138796a22d3294a51466b480ee969851f922e143abaeec8959d987c2424a0b2db6c92152f3103698e91afdb26a73471f4da6423db7fb383
data/lib/redis-lock.rb CHANGED
@@ -101,4 +101,21 @@ class Redis::Lock
101
101
  result = @@unlock_script.eval(@redis, :keys => [@key], :argv => [@token])
102
102
  !!result
103
103
  end
104
+
105
+ def extend
106
+ now = Time.now.to_i
107
+ @@extend_script ||= Script.new <<-LUA
108
+ local key = KEYS[1]
109
+ local expires_at = tonumber(ARGV[1])
110
+ local token = ARGV[2]
111
+
112
+ if redis.call('hget', key, 'token') == token then
113
+ redis.call('hset', key, 'expires_at', expires_at)
114
+ return true
115
+ else
116
+ return false
117
+ end
118
+ LUA
119
+ !!@@extend_script.eval(@redis, :keys => [@key], :argv => [now + @expire, @token])
120
+ end
104
121
  end
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class Lock
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robust-redis-lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kareem Kouddous
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-19 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: redis
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  description: Robust redis lock
@@ -35,31 +32,30 @@ extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
37
34
  - lib/redis-lock.rb
35
+ - lib/robust-redis-lock.rb
38
36
  - lib/robust-redis-lock/script.rb
39
37
  - lib/robust-redis-lock/version.rb
40
- - lib/robust-redis-lock.rb
41
38
  homepage: http://github.com/crowdtap/robust-redis-lock
42
39
  licenses: []
40
+ metadata: {}
43
41
  post_install_message:
44
42
  rdoc_options: []
45
43
  require_paths:
46
44
  - lib
47
45
  required_ruby_version: !ruby/object:Gem::Requirement
48
- none: false
49
46
  requirements:
50
- - - ! '>='
47
+ - - ">="
51
48
  - !ruby/object:Gem::Version
52
49
  version: '0'
53
50
  required_rubygems_version: !ruby/object:Gem::Requirement
54
- none: false
55
51
  requirements:
56
- - - ! '>='
52
+ - - ">="
57
53
  - !ruby/object:Gem::Version
58
54
  version: '0'
59
55
  requirements: []
60
56
  rubyforge_project:
61
- rubygems_version: 1.8.25
57
+ rubygems_version: 2.2.0
62
58
  signing_key:
63
- specification_version: 3
59
+ specification_version: 4
64
60
  summary: Robust redis lock
65
61
  test_files: []