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.