Skip to content

Conversation

@JPrevost
Copy link
Member

@JPrevost JPrevost commented Sep 29, 2025

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):

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.

Developer

Accessibility
  • ANDI or WAVE has been run in accordance to our guide.
  • This PR contains no changes to the view layer.
  • New issues flagged by ANDI or WAVE have been resolved.
  • New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
  • No new accessibility issues have been flagged.
New ENV
  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.
Approval beyond code review
  • UXWS/stakeholder approval has been confirmed.
  • UXWS/stakeholder review will be completed retroactively.
  • UXWS/stakeholder review is not needed.
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
  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.
Documentation
  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.
Testing
  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

@mitlib mitlib temporarily deployed to timdex-ui-pi-use-32-cac-i0mqbe September 29, 2025 17:56 Inactive
@coveralls
Copy link

coveralls commented Sep 29, 2025

Pull Request Test Coverage Report for Build 18288683997

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 98.99%

Totals Coverage Status
Change from base Build 18170555247: 0.01%
Covered Lines: 784
Relevant Lines: 792

💛 - Coveralls

@jazairi jazairi self-assigned this Oct 6, 2025
Copy link
Contributor

@jazairi jazairi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@JPrevost JPrevost merged commit 0baa069 into main Oct 6, 2025
5 checks passed
@JPrevost JPrevost deleted the use-32-caching branch October 6, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants