Add dirties option to Model.uncached
Created by: djmb
Motivation / Background
This is an alternative to https://github.com/rails/rails/pull/50721.
For Solid Cache, we want to be able to read and write from the cache database without using the query cache.
We also don't want to expire the query cache on other connection pools when we write. Writing to the Rails cache shouldn't invalidate the main query cache.
cc @byroot, @jeremy
Detail
This adds a dirties
option to ActiveRecord::Base.uncached
and ActiveRecord::ConnectionAdapters::ConnectionPool#uncached
.
Setting dirties
to false
, means database writes to the connection pool will not mark any query caches as dirty.
The option defaults to true
which retains the existing behaviour and clears query caches on all connection pools used by the current thread.
Additional information
Checklist
Before submitting the PR make sure the following are checked:
-
This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs. -
Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
-
Tests are added or updated if you fix a bug or add a feature. -
CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.