Repository navigation
Releases: bdurand/support_table_cache
Releases · bdurand/support_table_cache
Release list
v1.1.6
Fixed
- Queries on relations with conditions that cannot be represented in the cache key (SQL string conditions, ranges,
not,or, joins,group,having,from,offset, locking, or non-hashfind_byarguments) now bypass the cache instead of silently ignoring those conditions and returning or caching the wrong record. create_withvalues are no longer included in cache keys, so queries usingcreate_withcan now be cached correctly.- Queries inside an open transaction now bypass the cache so that uncommitted data can never be cached. Previously a rolled back transaction could permanently poison the cache with data that was never committed. Transactions created with
joinable: false(such as Rails transactional test fixtures) still use the cache. - Cache invalidation now runs even when caching is disabled. Previously records changed inside a
disableblock (or while caching was disabled globally) left stale entries behind for when caching was re-enabled. - Cache key values are now cast through the attribute type, so equivalent values (e.g.
:oneand"one", or"5"and5) produce the same cache key. Previously such entries could be written under keys that the invalidation callbacks could never delete. This also fixes cache keys forfalseattribute values, which were previously indistinguishable fromnil. load_cacheno longer raises an error when caching is disabled and now honorswhereconditions oncache_byconfigurations instead of caching records that do not match them. It also refreshes existing cache entries instead of skipping them.- A
cache_byconfiguration whosewhereclause does not match a query no longer prevents later configurations from matching, and no longer mutates the query attributes while matching. - Calling
cache_byin a subclass no longer mutates the superclass's cache configuration. - Models that include
SupportTableCachewithout callingcache_byno longer raise an error onfind_by. - Calling
cache_belongs_tomore than once for the same association no longer causes infinite recursion when reading the association. SupportTableCache::MemoryCachenow synchronizes all access to the underlying hash (previously reads, deletes, and clears were unsynchronized), purges expired entries, and no longer serializes values twice on a cache miss. Afetchthat races with a concurrentdeleteorclearno longer stores its stale value back in the cache.- The
whereclause on acache_byconfiguration is now matched against query attributes using values cast through the attribute type, so equivalent values (e.g.1and"1") match the same way they do when building cache keys. - A
find_bythat specifies a different value for an attribute than the relation it is chained onto (i.e.where(name: "Two").find_by(name: "One")) now bypasses the cache. Previously thefind_byvalue replaced the relation's value in the cache key so a cached record excluded by the relation could be returned. fetch_byandfetch_by!now raise anArgumentErrorif a query cannot be matched to a cache key because it does not satisfy thewherecondition on acache_byconfiguration or because it conflicts with the relation it is chained onto. Previously these queries silently fell back to the database, which defeats the purpose of the safety check. Queries on a model with a default scope matching acache_bywherecondition no longer raise an error.SupportTableCache::FiberLocalsnow stores state in the fiber's native local storage so that state cannot leak from fibers that are garbage collected while suspended inside a block.
Full Changelog: v1.1.5...v1.1.6
v1.1.5
Fixed
- Replaced thread local variables with fiber local variables to prevent the possibility of behavior from leaking across fibers when disabling the cache in a block.
- Allow setting the cache to an in-memory cache by setting
support_table_cachetotrue.
Full Changelog: v1.1.4...v1.1.5
v1.1.4
Fixed
- Fixed issue where using
find_byon ahas_manyrelation would not take the scope of the relation into account when looking up the cached record. Now chaining afind_byonto ahas_manyrelation will correctly bypass the cache and directly query the database.
Full Changelog: v1.1.3...v1.1.4
v1.1.3
Fixed
- Avoid calling methods that require a database connection when setting up belongs to caching.
Full Changelog: v1.1.2...v1.1.3