unique_thread 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/unique_thread/redis_lua/extend_lock.lua +11 -0
- data/lib/unique_thread/redis_lua/get_lock.lua +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da0b2a8f7bf6e6be0baa044b53d85c1e5903a3c0
|
4
|
+
data.tar.gz: a9a6f8b6f7097b0abef203c016dd3051a1e2cdb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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-
|
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:
|