identity_cache 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +20 -5
- data/lib/identity_cache/query_api.rb +2 -0
- data/lib/identity_cache/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3abed29487ae94532060d1a35e2bc86f8b4187cbc9a3074c8c304ab4f8426b4b
|
4
|
+
data.tar.gz: ddcaf494c9bc48055ee4e1ddc83a5caf61e047e4d053eb2b4e87a086a73f97ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0c8e9d0996d6f7f3f3e760fbf1ec2f7b8fa819bbeeaa3dc8b1286125265da45c6b174a77d3b13f763e6db104d613a55562f0a0ff13eb6d0c800e455ae30020c
|
7
|
+
data.tar.gz: 03a5cffffa5a0971f0d12a4d449c518a471d579410c2f7b8dfe32ad82234fb08115fa44cc99e726ed28352ead0287c5e966f47fb0b607758ddb29b1baa4667a4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -254,11 +254,26 @@ Cache keys include a version number by default, specified in `IdentityCache::CAC
|
|
254
254
|
|
255
255
|
## Caveats
|
256
256
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
257
|
+
IdentityCache is never going to be 100% consistent, since cache invalidations can be lost. As such, it was intentionally designed to be _opt-in_, so it is only used where cache inconsistency is tolerated. This means IdentityCache does not mess with the way normal Rails associations work, and including it in a model won't change any clients of that model until you switch them to use `fetch` instead of `find`. This means that you need to think carefully about when you use `fetch` and when you use `find`.
|
258
|
+
|
259
|
+
Expected sources of lost cache invalidations include:
|
260
|
+
* Database write performed that doesn't trigger an after_commit callback
|
261
|
+
* Process/system getting killed or crashing between the database commit and cache invalidation
|
262
|
+
* Network unavailability, including transient failures, preventing the delivery of the cache invalidation
|
263
|
+
* Memcached unavailability or failure preventing the processing of the cache invalidation request
|
264
|
+
* Memcached flush / restart could remove a cache invalidation that would normally interrupt a cache fill that started when the cache key was absent. E.g.
|
265
|
+
1. cache key absent (not just invalidated)
|
266
|
+
2. process 1 reads cache key
|
267
|
+
3. process 1 starts reading from the database
|
268
|
+
4. process 2 writes to the database
|
269
|
+
5. process 2 writes a cache invalidation marker to cache key
|
270
|
+
6. memcached flush
|
271
|
+
7. process 1 uses an `ADD` operation, which succeeds in filling the cache with the now stale data
|
272
|
+
* Rollout of cache namespace changes (e.g. from upgrading IdentityCache, adding columns, cached associations or from application changes to IdentityCache.cache_namespace) can result in cache fills to the new namespace that aren't invalidated by cache invalidations from a process still using the old namespace
|
273
|
+
|
274
|
+
Cache expiration is meant to be used to help the system recover, but it only works if the application avoids using the cache data as a transaction to write data. IdentityCache avoids loading cached data from its methods during an open transaction, but can't prevent cache data that was loaded before the transaction was opened from being used in a transaction. IdentityCache won't help with scaling write traffic, it was intended for scaling database queries from read-only requests.
|
275
|
+
|
276
|
+
IdentityCache also caches the absence of database values (e.g. to avoid performance problems when it is destroyed), so lost cache invalidations can also result in that value continuing to remain absent. As such, avoid sending the id of an uncommitted database record to another process (e.g. queuing it to a background job), since that could result in an attempt to read the record by its id before it has been created. A cache invalidation will still be attempted when the record is created, but that could be lost.
|
262
277
|
|
263
278
|
## Notes
|
264
279
|
|
@@ -70,6 +70,8 @@ module IdentityCache
|
|
70
70
|
readonly: IdentityCache.fetch_read_only_records && should_use_cache?)
|
71
71
|
return if records.empty?
|
72
72
|
|
73
|
+
return unless should_use_cache?
|
74
|
+
|
73
75
|
records.each(&:readonly!) if readonly
|
74
76
|
each_id_embedded_association do |cached_association|
|
75
77
|
preload_id_embedded_association(records, cached_association)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: identity_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Lopez
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2023-
|
17
|
+
date: 2023-03-23 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.4.9
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: IdentityCache lets you specify how you want to cache your model objects,
|