istox 0.2.14.2 → 0.2.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/istox/helpers/race_condition_helper.rb +10 -0
- data/lib/istox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 191d8ea6fdad58b0fe99961ac461eaaab8d80e684172b11632d056e27f9b6c92
|
4
|
+
data.tar.gz: c69b2ef4fbd2ee80619690ba61cd434f6f527f95ea2cb3c9dd44e35cc997200e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3c49ba90cb39a0773de6bc7781d08c66e1db7356d214c2c971fd0dae7b4d0daa92c5e9fda2426df67cd2a8ffa13816d263946aab46ca564833ff6cc6e220b36
|
7
|
+
data.tar.gz: 78f888d34684fc979354b8bc13b781f0f9aee530c2ffa0f46285298f460dda6a96c235a47856b25e711cf853df5208a0e98e02b3e3d4c3080d14219697d84038
|
@@ -22,6 +22,16 @@ module Istox
|
|
22
22
|
log.info("Releasing lock for key: #{key}")
|
23
23
|
end
|
24
24
|
|
25
|
+
### lock with block
|
26
|
+
def lock!(key, expired_seconds: 20)
|
27
|
+
acquire!(key, expired_seconds: expired_seconds)
|
28
|
+
yield
|
29
|
+
release(key)
|
30
|
+
rescue StandardError => e
|
31
|
+
release(key)
|
32
|
+
raise e
|
33
|
+
end
|
34
|
+
|
25
35
|
def request_redis
|
26
36
|
@request_redis ||= ::Istox::RedisManager.request_redis
|
27
37
|
end
|
data/lib/istox/version.rb
CHANGED