Commit 9b1e897
committed
Adds caching for timdex api queries
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.1 parent a86ecf7 commit 9b1e897
2 files changed
+36
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
27 | 43 | | |
28 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
29 | 51 | | |
30 | 52 | | |
31 | 53 | | |
| |||
59 | 81 | | |
60 | 82 | | |
61 | 83 | | |
62 | | - | |
| 84 | + | |
63 | 85 | | |
64 | 86 | | |
65 | 87 | | |
66 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
67 | 91 | | |
68 | 92 | | |
69 | 93 | | |
| |||
78 | 102 | | |
79 | 103 | | |
80 | 104 | | |
81 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
82 | 108 | | |
83 | 109 | | |
84 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
0 commit comments