-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We want to avoid using the ActiveRecord query cache entirely with SolidCache: - Read queries don't need to be cached as that is handled by the local cache - Write queries should not clear the query cache, as you would not expect `Rails.cache.write` to clear out the entire query cache. Ideally we'd just be able to do something like: ```ruby class SolidCache::Record self.uses_query_cache = false end ``` Absent that we need to do a bunch of gymnastics to get the behaviour we want. 1. Selects This is easy enough, we just wrap the query in an `uncached` block 2. Upserts Here we need to avoid calling `connection.exec_insert_all` as that will dirty the query cache. Instead we have to construct the SQL manually and execute it with `connection.exec_query`. 3. Deletes Similarly we need to avoid calling `connection.delete` here. Again we construct the SQL manually and execute it with `connection.exec_delete`.
- Loading branch information
Showing
2 changed files
with
48 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters