Commit 5f47864
authored
fix: improve caching behavior of database integration (#444)
This improves the caching behavior of the Lazy Load data system.
Previously, calling `AllFlags` or `AllSegments` updated an "allFlags" or
"allSegments" key in the unscoped freshness tracker. That's correct, as
those keys act as rate limiters for the "all" queries.
It then upserted each individual item in the _unscoped_ freshness
tracker.
This is not optimal, as the unscoped tracker is not referenced when we
read individual items. This results in cache misses for individual
items, even after they were all refreshed.
This change properly adds the individual items into the scoped tracker.
Now, `AllFlags` or `AllSegments` should result in "priming" the cache
for future individual item fetches.
This does have the behavior of syncing the TTL dates of all items to a
single point in time.
-------------
Before:
```
[LaunchDarkly] lazy load via redis (JSON): get allFlags - cache miss
[LaunchDarkly] lazy load via redis (JSON): get allSegments - cache miss
[LaunchDarkly] lazy load via redis (JSON): get test - cache miss
[LaunchDarkly] lazy load via redis (JSON): get my-boolean-flag - cache miss
```
After:
```
[LaunchDarkly] lazy load via redis (JSON): get allFlags - cache miss
[LaunchDarkly] lazy load via redis (JSON): get allSegments - cache miss
[LaunchDarkly] lazy load via redis (JSON): get test - cache hit
[LaunchDarkly] lazy load via redis (JSON): get my-boolean-flag - cache hit
```1 parent 4a7f1f9 commit 5f47864
File tree
1 file changed
+4
-3
lines changed- libs/server-sdk/src/data_systems/lazy_load
1 file changed
+4
-3
lines changedLines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | | - | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| |||
0 commit comments