atomic_cache 0.5.0.rc1 → 0.5.1.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7362eab306c19b619c6eb4bd30501b2b18194cd9e870a344e45b39c6ff18b4ae
4
- data.tar.gz: cce7666dec7a66bca3717cb7278bcdb9d7b81aaffc8c68fb020e15e02820f921
3
+ metadata.gz: f03b8f8d9294f3a40ea719ea5165d4c6789c3eebb36459768c8fbd0c57d8fc3a
4
+ data.tar.gz: b2a320b8323c57785e0202e29d89922b33e63fc9ebd898d6df61f76fb5e2600c
5
5
  SHA512:
6
- metadata.gz: b418f307870a20aa99b326644c14066d3baba30287138ce2a4b533582d788231058c0f3f66737fcf19225cdadbcf5dbb78653d7969ade7eb7555a7c3f849b4c2
7
- data.tar.gz: c9f48abddc3b0f9d623db83bd493df4fd555ae468710251dd13db6ed684399052b52a48ffec516f96ae17a1ccc747416688b2234f514ef8278bba0fd4ed550d2
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
- # if the value of the last known key is nil, we can infer that it's
123
- # most likely expired, thus remove it so other processes don't waste
124
- # time trying to read it
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AtomicCache
4
- VERSION = "0.5.0.rc1"
4
+ VERSION = "0.5.1.rc1"
5
5
  end
@@ -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.0.rc1
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-08 00:00:00.000000000 Z
12
+ date: 2021-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler