Adds caching for timdex api queries#226
Merged
Merged
Conversation
Pull Request Test Coverage Report for Build 18288683997Details
💛 - Coveralls |
jazairi
approved these changes
Oct 6, 2025
jazairi
left a comment
Contributor
There was a problem hiding this comment.
Works as expected locally. Thanks for setting the foundation for Primo caching. :)
Why are these changes being introduced: * As we scale up usage of Timdex, we want to reduce load on the backend by caching while also improving response times for users. * We will extend this caching to Primo API in the future, which is a much slower API so this will be even more beneficial than this initial caching for Timdex. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-32 How does this address that need: * Uses Rails.cache to cache Timdex API responses for 12 hours * Cache key is based on the incoming search paramters along with the geo or use flag to ensure different caches for different contexts Document any side effects to this change: * We had to change the results to a hash to allow for caching. This required some changes to the search controller and analyzer model. No tests were changed and they continue to work, so hopefully these changes are not breaking anything else. * In development, `bin/rails dev:cache` will toggle between an in memory cache or null cache, so you can test caching behavior locally. * In production, if Redis is available it will be used for cacheing. It is currently enabled in GDT, but not USE. USE will have redis added, but our staging environments do not really need redis so we may need to adjust some configuration if the apps don't silenetly fail to not having a cache.
0dd9e6d to
9b1e897
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes being introduced:
Relevant ticket(s):
How does this address that need:
Document any side effects to this change:
bin/rails dev:cachewill toggle between an in memory cache or null cache, so you can test caching behavior locally.Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing