-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ActiveRecord query cache workarounds #123
Comments
Add the ability to ignore the query cache in a block. In the block, - queries will not be cached - queries will not be read from the cache - writes will not clear the cache - cached/uncached blocks will be ignored This is something we need for Solid Cache (see rails/solid_cache#123). As Solid Cache uses the database it gets the automatic query cache behaviour by default. But it would be better if it ignored the query cache entirely. The local cache already handles caching repeated reads and having cache writes clear the AR query cache is not desirable. `uncached` works for disabling reads doesn't disable clearing the cache for writes.
Add the ability to ignore the query cache in a block. In the block, - queries will not be cached - queries will not be read from the cache - writes will not clear the cache - cached/uncached blocks will be ignored This is something we need for Solid Cache (see rails/solid_cache#123). As Solid Cache uses the database it gets the automatic query cache behaviour by default. But it would be better if it ignored the query cache entirely. The local cache already handles caching repeated reads and having cache writes clear the AR query cache is not desirable. `uncached` works for disabling reads doesn't disable clearing the cache for writes.
Add the ability to ignore the query cache in a block. In the block, - queries will not be cached - queries will not be read from the cache - writes will not clear the cache - cached/uncached blocks will be ignored This is something we need for Solid Cache (see rails/solid_cache#123). As Solid Cache uses the database it gets the automatic query cache behaviour by default. But it would be better if it ignored the query cache entirely. The local cache already handles caching repeated reads and having cache writes clear the AR query cache is not desirable. `uncached` works for disabling reads doesn't disable clearing the cache for writes.
Add the ability to ignore the query cache in a block. In the block, - queries will not be cached - queries will not be read from the cache - writes will not clear the cache - cached/uncached blocks will be ignored This is something we need for Solid Cache (see rails/solid_cache#123). As Solid Cache uses the database it gets the automatic query cache behaviour by default. But it would be better if it ignored the query cache entirely. The local cache already handles caching repeated reads and having cache writes clear the AR query cache is not desirable. `uncached` works for disabling reads doesn't disable clearing the cache for writes.
Think this is ultimately the way to go. It's the model that knows it needs a "direct" mode, so it needs to request as much from the connection it's using, rather than the connection needing to be configured that way. It is a rare need indeed, though. Getting something like that into Rails could be approached as a side effect of fixing the cross-connection cache invalidation problem. If cluster/schema mutations are advertised for others to observe, the connection could get out of the business of deciding whose caches need clearing. The Solid Cache model could still advertise that it was mutated, but now with the expectation that nobody else is paying attention. |
With rails/rails#51204, we'll be able to remove these. We'll do this in a future version once Rails 7.2 is released. |
We don't want Solid Cache to interact with the ActiveRecord query cache at all.
So results should not be cached (which we achieve by wrapping queries in
uncached
blocks, but also we should avoid invalidating the AR query cache when we write).At the moment this is done by dropping down to lower level methods that are not wrapped with
dirties_query_cache
.This is not ideal and is relying on undocumented behaviour that could change in future releases.
Instead I think we need a way to disable the query cache invalidation in Rails. It would be nice to be able to set something on
SolidCache::Record
to say it doesn't use the query cache at all, but I don't think that will work as the query cache is a connection based, not model based.We probably need another method similar to
uncached
that can totally disable the query cache.The text was updated successfully, but these errors were encountered: