atomic_cache 0.5.0.rc1 → 0.5.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atomic_cache/atomic_cache_client.rb +3 -5
- data/lib/atomic_cache/key/last_mod_time_key_manager.rb +7 -0
- data/lib/atomic_cache/version.rb +1 -1
- data/spec/atomic_cache/atomic_cache_client_spec.rb +0 -7
- data/spec/atomic_cache/key/last_mod_time_key_manager_spec.rb +9 -0
- 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: f03b8f8d9294f3a40ea719ea5165d4c6789c3eebb36459768c8fbd0c57d8fc3a
|
4
|
+
data.tar.gz: b2a320b8323c57785e0202e29d89922b33e63fc9ebd898d6df61f76fb5e2600c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f461c2bf7d903c6f7940334b8f5d11672c7ed04d1d55ad5d25c2337c07906d24a39f8958ddf04a2dd5d5dc690c9a0920121fb99c9f25c809c08959e48ee13ae3
|
7
|
+
data.tar.gz: 9100ad9f5e5012c3729e3bc3a3b95ca64705c562f14e5d610df9f223436ee9351ec58cddc64b61c87c186a588f18e6158e891308aa5d431739f56aa2562744fa
|
@@ -119,13 +119,11 @@ module AtomicCache
|
|
119
119
|
return lkv
|
120
120
|
end
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
@storage.delete(lkk)
|
122
|
+
metrics(:increment, 'last-known-value.nil', tags: tags)
|
123
|
+
else
|
124
|
+
metrics(:increment, 'last-known-value.not-present', tags: tags)
|
126
125
|
end
|
127
126
|
|
128
|
-
metrics(:increment, 'last-known-value.not-present', tags: tags)
|
129
127
|
nil
|
130
128
|
end
|
131
129
|
|
@@ -59,6 +59,13 @@ module AtomicCache
|
|
59
59
|
@storage.add(keyspace.lock_key, LOCK_VALUE, ttl, options)
|
60
60
|
end
|
61
61
|
|
62
|
+
# check if the keyspace is locked
|
63
|
+
#
|
64
|
+
# @param keyspace [AtomicCache::Keyspace] keyspace to lock
|
65
|
+
def lock_present?(keyspace)
|
66
|
+
@storage.read(keyspace.lock_key) == LOCK_VALUE
|
67
|
+
end
|
68
|
+
|
62
69
|
# remove existing lock to allow other processes to update keyspace
|
63
70
|
#
|
64
71
|
# @param keyspace [AtomicCache::Keyspace] keyspace to lock
|
data/lib/atomic_cache/version.rb
CHANGED
@@ -168,13 +168,6 @@ describe 'AtomicCacheClient' do
|
|
168
168
|
result = subject.fetch(keyspace, backoff_duration_ms: 5) { 'value from generate' }
|
169
169
|
expect(result).to eq(nil)
|
170
170
|
end
|
171
|
-
|
172
|
-
it 'deletes the last known key' do
|
173
|
-
key_storage.set(keyspace.last_known_key_key, :oldkey)
|
174
|
-
cache_storage.set(:oldkey, nil)
|
175
|
-
subject.fetch(keyspace, backoff_duration_ms: 5) { 'value from generate' }
|
176
|
-
expect(cache_storage.store).to_not have_key(:oldkey)
|
177
|
-
end
|
178
171
|
end
|
179
172
|
end
|
180
173
|
end
|
@@ -40,6 +40,15 @@ describe 'LastModTimeKeyManager' do
|
|
40
40
|
expect(storage.store).to_not have_key(:'ns:lock')
|
41
41
|
end
|
42
42
|
|
43
|
+
it 'checks if the lock is present' do
|
44
|
+
subject.lock(req_keyspace, 100)
|
45
|
+
expect(subject.lock_present?(req_keyspace)).to eq(true)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'checks if the lock is not present' do
|
49
|
+
expect(subject.lock_present?(req_keyspace)).to eq(false)
|
50
|
+
end
|
51
|
+
|
43
52
|
it 'promotes a timestamp and last known key' do
|
44
53
|
subject.promote(req_keyspace, last_known_key: 'asdf', timestamp: timestamp)
|
45
54
|
expect(storage.read(:'ns:lkk')).to eq('asdf')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ibotta Developers
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-07-
|
12
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|