This project is archived and is in readonly mode.
Strategy::LocalCache doesn't work with multiple caching methods
Reported by jeffsc | December 18th, 2009 @ 08:28 PM
I'm using Strategy::LocalCache to provide solely a per-request local cache (by implementing a caching strategy that extends LocalCache but does nothing itself). When I upgraded from 2.3.4 -> 2.3.5, LocalCache stopped working.
The problem is that when the klass is created in middleware, the thread_local_key is evaluated once at load, and is fixed as that no matter where it is used. In this case, it is fixed at active_support_mem_cache_store_local_cache.
At runtime, it uses a key for whatever class is currently being used; in my case, active_support_request_store_local_cache. Therefore it doesn't match the key that was used to set up a new MemoryStore; and it always results in a nil local_cache.
The end result is that LocalCache only works if you use it for a single cache store, but fails if you try it use it for another one.
Test cache implementation is attached; put this file in lib/active_support_cache and try to use RequestStore as your caching strategy -- it will always fail to find the key you just put in the cache. It should find the key if the read is within the same request as the write; and fail only if it is across requests.
Comments and changes to this ticket
-
josh December 20th, 2009 @ 10:58 PM
- State changed from new to incomplete
LocalCache was only designed to work with Memcache. Its interesting that it sort of works in other cases. If you come up with a fix, I'd gladly commit.
-
josh December 20th, 2009 @ 10:58 PM
- State changed from incomplete to wontfix
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>