robust-redis-lock 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5f81aecb46ec64804f60f5d67066896cbe05eb0
4
- data.tar.gz: 7424bac609f9bf243345733935d3618ef2395ba5
3
+ metadata.gz: 7f2fa7e0d73f535b0954a4c2230d10c1210756c5
4
+ data.tar.gz: 6ade50d147b687dbd9c5d05c073e396200bd34d9
5
5
  SHA512:
6
- metadata.gz: 11470af19b0e99a204d705ec229bfe2a8ea01279a1cb1af904a0f9f3c605483ffcf8c5fcb58572add121c8ab1d5f039a54397faefe4a9a0d656dd3033321a0aa
7
- data.tar.gz: a050eb216fe5a95d117ba4d0f3bb69b8265b7b6fae11f7136c36aeaa27ad1b1daa0fb094d42cf2e8e41e1825916de208218d5d7ab9a1afb754b7c41650c6c5b9
6
+ metadata.gz: 3916b3b7333f21bd8aea9f56a019b61be216a5a4c54fd3a56ecfea874836a8d5049796a7fa895c0bfdc41ac166f5bd0efcd9012805bdefe09624f2959b6a893d
7
+ data.tar.gz: 21963e31733c5b397bbf4696ad9ab382e2fdf21c271e4c528b4c8ea442fde15a19f939bf269c0ce25027e0c08b12aa5d5270216d167a2b2581c7b99d7f48bf4b
@@ -77,7 +77,10 @@ class Redis::Lock
77
77
  end
78
78
 
79
79
  def data
80
- @data ||= @serializer.load(@redis.hget(key, 'data'))
80
+ @data ||= begin
81
+ raw = @redis.hget(key, 'data')
82
+ @serializer.load(raw) if raw
83
+ end
81
84
  end
82
85
 
83
86
  def try_lock
@@ -100,8 +103,10 @@ class Redis::Lock
100
103
 
101
104
  redis.call('hset', key, 'expires_at', expires_at)
102
105
  redis.call('hset', key, 'token', next_token)
103
- redis.call('hset', key, 'data', data)
104
106
  redis.call('zadd', key_group, expires_at, key)
107
+ if data then
108
+ redis.call('hset', key, 'data', data)
109
+ end
105
110
 
106
111
  if prev_expires_at then
107
112
  return {'recovered', next_token}
@@ -109,7 +114,7 @@ class Redis::Lock
109
114
  return {'acquired', next_token}
110
115
  end
111
116
  LUA
112
- result, token = @@lock_script.eval(@redis, :keys => [@key, @key_group_key], :argv => [now.to_i, now.to_i + @expire, @serializer.dump(@data)])
117
+ result, token = @@lock_script.eval(@redis, :keys => [@key, @key_group_key], :argv => [now.to_i, now.to_i + @expire, @serializer.dump(data)])
113
118
 
114
119
  @token = token if token
115
120
 
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class Lock
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robust-redis-lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kareem Kouddous