cloudtasker 0.10.rc3 → 0.10.rc4
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/cloudtasker/redis_client.rb +6 -1
- data/lib/cloudtasker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 228f7fc8ef7ca52a1a9827b233ae1ebfea77e2a6d6683d68caa3fffef697ffb4
|
4
|
+
data.tar.gz: b58fee4392d02847c462684744a5b90ff413564a02e3e74b51514b7f8aee4107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d7bfd9d4bbdb38ca48cf5e3af1fd9f901a3f89b84bce7d41609baa22d7ded5ce0c3a657d8aaaa9ad3b9274ad389825bdd7e17272f65ef80a68c6cb96538d25
|
7
|
+
data.tar.gz: b0a1f08dd892a9c709ecb24fb9a38c6507489179ce06779e49c9641d1ed849b02af6c3717476d85e7cf852879d0a5c8429123bc843a4ce60933f8319d0241e5a
|
@@ -7,6 +7,8 @@ module Cloudtasker
|
|
7
7
|
class RedisClient
|
8
8
|
# Suffix added to cache keys when locking them
|
9
9
|
LOCK_KEY_PREFIX = 'cloudtasker/lock'
|
10
|
+
LOCK_DURATION = 2 # seconds
|
11
|
+
LOCK_WAIT_DURATION = 0.03 # seconds
|
10
12
|
|
11
13
|
def self.client
|
12
14
|
@client ||= Redis.new(Cloudtasker.config.redis || {})
|
@@ -51,6 +53,9 @@ module Cloudtasker
|
|
51
53
|
#
|
52
54
|
# Acquire a lock on a cache entry.
|
53
55
|
#
|
56
|
+
# Locks are enforced to be short-lived (2s).
|
57
|
+
# The yielded block should limit its logic to short operations (e.g. redis get/set).
|
58
|
+
#
|
54
59
|
# @example
|
55
60
|
# redis = RedisClient.new
|
56
61
|
# redis.with_lock('foo')
|
@@ -65,7 +70,7 @@ module Cloudtasker
|
|
65
70
|
|
66
71
|
# Wait to acquire lock
|
67
72
|
lock_key = [LOCK_KEY_PREFIX, cache_key].join('/')
|
68
|
-
|
73
|
+
sleep(LOCK_WAIT_DURATION) until client.set(lock_key, true, nx: true, ex: LOCK_DURATION)
|
69
74
|
|
70
75
|
# yield content
|
71
76
|
yield
|
data/lib/cloudtasker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudtasker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Lachaume
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|