cloudtasker 0.10.rc3 → 0.10.rc4

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
  SHA256:
3
- metadata.gz: 4b2692b6e4fe2fbd98cf70fb2fe7a2027992d83be63188108113d523cf410160
4
- data.tar.gz: 892910f2b59d84e2f516478926fefb63bd913bb4db4507133cde614eca933482
3
+ metadata.gz: 228f7fc8ef7ca52a1a9827b233ae1ebfea77e2a6d6683d68caa3fffef697ffb4
4
+ data.tar.gz: b58fee4392d02847c462684744a5b90ff413564a02e3e74b51514b7f8aee4107
5
5
  SHA512:
6
- metadata.gz: 3f7a4bc94036af569901cde01fe7596acc9eea3019d9216db033de2833eb471668f231c6dbf00ac231247f599291fdd0bec0ed4eb700cf06521b01ea2a753739
7
- data.tar.gz: f37e39c7ce6fff9a755a457694f5b46aca1c64b9a46b8b1fa74e10208e19c6c6beffc7e5c4e50a74040d1cca8032088478be2168f80f17e2be4d1845d4d69306
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
- true until client.setnx(lock_key, true)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cloudtasker
4
- VERSION = '0.10.rc3'
4
+ VERSION = '0.10.rc4'
5
5
  end
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.rc3
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-04-21 00:00:00.000000000 Z
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport