atomic_cache 0.5.2.rc1 → 0.5.3.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 +4 -4
- data/docs/USAGE.md +6 -0
- data/lib/atomic_cache/atomic_cache_client.rb +0 -10
- data/lib/atomic_cache/version.rb +1 -1
- data/spec/atomic_cache/atomic_cache_client_spec.rb +0 -20
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508ff6dd988d3b864438c2c54d3bca4cba2490a62c2ae97ed2b313522d5e8694
|
4
|
+
data.tar.gz: e0cd9a214c089780758955d2642c406484e0404c669d87faf347de1d8cb3a781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e751211a50a029cf4043fa89bf74e50cb200835985c884b5a0faa782b9fc3b8b4c9a0b55be561763363c6625e124c9c11bee75cb15596ddea7b7213bb20bc7
|
7
|
+
data.tar.gz: b3fa0f5bed38fe417103a02409fcb1bf9ccb7611d69887ac6b5cc565e1440a6148ab9f306cb3283fbce2369bf26012f2532a21e889871a47e22d3a517f8b9b84
|
data/docs/USAGE.md
CHANGED
@@ -38,6 +38,12 @@ The ideal `generate_ttl_ms` time is just slightly longer than the average genera
|
|
38
38
|
|
39
39
|
If metrics are enabled, the `<namespace>.generate.run` can be used to determine the min/max/average generate time for a particular cache and the `generate_ttl_ms` tuned using that.
|
40
40
|
|
41
|
+
##### ⚠️ TTL Rounding
|
42
|
+
When using atomic_cache with memcached, be aware that the TTL will be rounded down to the nearest whole seconds. For example, a `generate_ttl_ms` value of 3500 will result in a 3s TTL with memcache.
|
43
|
+
|
44
|
+
##### ⚠️ Max Rate of Change
|
45
|
+
Atomic_cache will *not* remove the lock after the generation process is done. This is both more efficient, and allows the `generate_ttl_ms` to be used to limit the total rate of change. For example, if the typical database query behind the cache takes 2s to run, but `generate_ttl_ms` is set to 10s, then the lock will live on for 8s after the generate process finishes, preventing other processes from querying for a new value. In many ways, `generate_ttl_ms` is the amount of time that the system will be un-allowed to make additional queries.
|
46
|
+
|
41
47
|
#### `max_retries` & `backoff_duration_ms`
|
42
48
|
_`max_retries` defaults to 5._
|
43
49
|
_`backoff_duration_ms` defaults to 50ms._
|
@@ -144,16 +144,6 @@ module AtomicCache
|
|
144
144
|
if !value.nil?
|
145
145
|
metrics(:increment, 'wait.present', tags: metrics_tags)
|
146
146
|
return value
|
147
|
-
else
|
148
|
-
# if we didn't get a fresh value this go-round, check if there's a last known value
|
149
|
-
# if expirations were to come in rapidly, it's possible that the expiration which caused
|
150
|
-
# the wait cycle wrote a value, and it's now in LKV, and a new expiration came in, which
|
151
|
-
# has moved the LMT forward
|
152
|
-
value = last_known_value(keyspace, options, tags)
|
153
|
-
if !value.nil?
|
154
|
-
metrics(:increment, 'wait.lkv.present', tags: metrics_tags)
|
155
|
-
return value
|
156
|
-
end
|
157
147
|
end
|
158
148
|
end
|
159
149
|
|
data/lib/atomic_cache/version.rb
CHANGED
@@ -163,26 +163,6 @@ describe 'AtomicCacheClient' do
|
|
163
163
|
expect(result).to eq(new_value)
|
164
164
|
end
|
165
165
|
|
166
|
-
it 'uses the last known value if the LMT increments while waiting' do
|
167
|
-
key_storage.set(timestamp_manager.last_modified_time_key, '1420090000')
|
168
|
-
key_storage.set(keyspace.last_known_key_key, 'lkk_key')
|
169
|
-
last_known_value = 'value from another thread'
|
170
|
-
|
171
|
-
# fetching the 'fresh' value continually returns nil (because LMT is incrementing forward)
|
172
|
-
allow(cache_storage).to receive(:read)
|
173
|
-
.with(timestamp_manager.current_key(keyspace), anything)
|
174
|
-
.and_return(nil, nil, nil, nil)
|
175
|
-
|
176
|
-
# multiple returned values are faking what it would look like if another process
|
177
|
-
# promoted a value (wrote LKV) but then the cache expired right after
|
178
|
-
allow(cache_storage).to receive(:read)
|
179
|
-
.with(timestamp_manager.last_known_key(keyspace), anything)
|
180
|
-
.and_return(nil, nil, nil, last_known_value)
|
181
|
-
|
182
|
-
result = subject.fetch(keyspace, backoff_duration_ms: 5) { 'value from generate' }
|
183
|
-
expect(result).to eq(last_known_value)
|
184
|
-
end
|
185
|
-
|
186
166
|
it 'stops waiting when the max retry count is reached' do
|
187
167
|
timestamp_manager.promote(keyspace, last_known_key: 'asdf', timestamp: 1420090000)
|
188
168
|
result = subject.fetch(keyspace, backoff_duration_ms: 5) { 'value from generate' }
|
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.3.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ibotta Developers
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: gems
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,9 +144,6 @@ dependencies:
|
|
144
144
|
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '4.2'
|
147
|
-
- - "<"
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '6'
|
150
147
|
type: :runtime
|
151
148
|
prerelease: false
|
152
149
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,9 +151,6 @@ dependencies:
|
|
154
151
|
- - ">="
|
155
152
|
- !ruby/object:Gem::Version
|
156
153
|
version: '4.2'
|
157
|
-
- - "<"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '6'
|
160
154
|
- !ruby/object:Gem::Dependency
|
161
155
|
name: murmurhash3
|
162
156
|
requirement: !ruby/object:Gem::Requirement
|