Commit 54cac4e
committed
feat: Drop persistent-store cache after FDv2 in-memory store init
Once the FDv2 in-memory store takes over as the active read source, the
persistent-store wrapper's three Guava caches are no longer consulted on reads
and roughly double the in-memory footprint of flag data (or worse, indefinitely,
in cacheForever() mode).
Add an internal DisableableCache capability interface implemented by
PersistentDataStoreWrapper. The wrapper's disableCache() sets a volatile
cacheDisabled flag and invalidates all three Guava caches. Every cache touch
site (isInitialized, init, get, getAll, upsert, getCacheStats,
pollAvailabilityAfterOutage) checks the flag and short-circuits to the core
when set; this is required because the caches are LoadingCache instances and
plain invalidation would auto-repopulate via the registered CacheLoaders on
the next get(). WriteThroughStore.maybeSwitchStore() probes for the interface
and invokes disableCache() inside the existing synchronized block, after the
active read store has been flipped to the in-memory store.
The PersistentDataStoreBuilder cache-config setters (cacheTime, cacheSeconds,
cacheMillis, cacheForever, noCaching, staleValuesPolicy, recordCacheStats)
remain functional during the bootstrap window for backward compatibility;
class-level javadoc explains that under FDv2 they only govern that window.
Naming note: the capability is named disableCache rather than the ticket's
clearCache so the verb conveys that the cache is off going forward, not just
emptied. This aligns with Python and Ruby's disable_cache and matches the
dotnet sibling PR.
Mirrors dotnet-core#274 (.NET), launchdarkly/python-server-sdk#426 (Python),
launchdarkly/ruby-server-sdk#384 (Ruby), and launchdarkly/go-server-sdk#373
(Go).1 parent cac1568 commit 54cac4e
6 files changed
Lines changed: 275 additions & 12 deletions
File tree
- lib/sdk/server/src
- main/java/com/launchdarkly/sdk/server
- integrations
- test/java/com/launchdarkly/sdk/server
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
Lines changed: 35 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
154 | 177 | | |
155 | 178 | | |
156 | 179 | | |
157 | 180 | | |
158 | 181 | | |
159 | 182 | | |
160 | 183 | | |
161 | | - | |
| 184 | + | |
162 | 185 | | |
163 | 186 | | |
164 | 187 | | |
| |||
187 | 210 | | |
188 | 211 | | |
189 | 212 | | |
190 | | - | |
| 213 | + | |
191 | 214 | | |
192 | 215 | | |
193 | 216 | | |
| |||
228 | 251 | | |
229 | 252 | | |
230 | 253 | | |
231 | | - | |
| 254 | + | |
232 | 255 | | |
233 | 256 | | |
234 | 257 | | |
| |||
242 | 265 | | |
243 | 266 | | |
244 | 267 | | |
245 | | - | |
| 268 | + | |
246 | 269 | | |
247 | 270 | | |
248 | 271 | | |
| |||
281 | 304 | | |
282 | 305 | | |
283 | 306 | | |
284 | | - | |
| 307 | + | |
285 | 308 | | |
286 | 309 | | |
287 | 310 | | |
| |||
297 | 320 | | |
298 | 321 | | |
299 | 322 | | |
300 | | - | |
| 323 | + | |
301 | 324 | | |
302 | 325 | | |
303 | 326 | | |
| |||
340 | 363 | | |
341 | 364 | | |
342 | 365 | | |
343 | | - | |
| 366 | + | |
344 | 367 | | |
345 | 368 | | |
346 | 369 | | |
| |||
443 | 466 | | |
444 | 467 | | |
445 | 468 | | |
446 | | - | |
447 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
448 | 472 | | |
449 | 473 | | |
450 | 474 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
39 | 48 | | |
40 | 49 | | |
41 | 50 | | |
| |||
Lines changed: 110 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
713 | 714 | | |
714 | 715 | | |
715 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
716 | 826 | | |
717 | 827 | | |
718 | 828 | | |
| |||
0 commit comments