unique_thread 0.1.0 → 0.1.1

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: 2861f1fe74d69bad9f3cd3b472d8f8442b676eeb
4
- data.tar.gz: a9c158c7b3e95b56739b386f4ded1ad6028b8889
3
+ metadata.gz: da0b2a8f7bf6e6be0baa044b53d85c1e5903a3c0
4
+ data.tar.gz: a9a6f8b6f7097b0abef203c016dd3051a1e2cdb9
5
5
  SHA512:
6
- metadata.gz: f5db23b797560f957aa04de3f8590353f13a922f56f367901860c0f9e68ab946084c1cd45b5e08b97c197a68770fab70e2382666b0a68d776688b5a103218cff
7
- data.tar.gz: 9912187f3f39a9f29e1742d591b1f99b90ce5e68b945fd1fb388743461633a1ee582461f83ca03fb1902e5e38ea276cbbd03b149638e9cba7b0425ef08b196d4
6
+ metadata.gz: 7e662fe91f55a1a70c68e71a70f12cf83dcb9191f47bd1df8ad52bbe155b222af03d20f37d70350b5667645d2cc8b4885c8cd2042bb522aba86c7f807fd4fbdd
7
+ data.tar.gz: e79b9b0a27c659651ef8c41fc8a8e4394de2a88977a4a76e3125daa1bddf7915cf416e886d494eaca754e17c6e1592adfc88055f061c31ac2134ec31ac9ce0b2
@@ -0,0 +1,11 @@
1
+ local name = KEYS[1]
2
+ local held_until = KEYS[2]
3
+ local extended_time = KEYS[3]
4
+ local locked_until = redis.call('get', name)
5
+
6
+ if locked_until == held_until then
7
+ redis.call('set', name, extended_time)
8
+ return {'1', extended_time}
9
+ else
10
+ return {'0', locked_until}
11
+ end
@@ -0,0 +1,16 @@
1
+ local name = KEYS[1]
2
+ local now = KEYS[2]
3
+ local extended_time = KEYS[3]
4
+ local raw = redis.call('get', name)
5
+ local locked_until = '0'
6
+
7
+ if raw then
8
+ locked_until = raw
9
+ end
10
+
11
+ if locked_until < now then
12
+ redis.call('set', name, extended_time)
13
+ return {'1', extended_time}
14
+ else
15
+ return {'0', locked_until}
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unique_thread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Seror
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-12 00:00:00.000000000 Z
11
+ date: 2018-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -38,6 +38,8 @@ extra_rdoc_files: []
38
38
  files:
39
39
  - lib/unique_thread.rb
40
40
  - lib/unique_thread/locksmith.rb
41
+ - lib/unique_thread/redis_lua/extend_lock.lua
42
+ - lib/unique_thread/redis_lua/get_lock.lua
41
43
  - lib/unique_thread/stopwatch.rb
42
44
  homepage: https://github.com/Ferdy89/unique_thread
43
45
  licenses: