File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
packages/sdk/src/core/flags Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,14 @@ export class CoreFlagsManager implements FlagsManager {
106106 } ;
107107 }
108108
109+ private removeStaleKeys ( validCacheKeys : Set < string > ) : void {
110+ for ( const key of this . cache . keys ( ) ) {
111+ if ( ! validCacheKeys . has ( key ) ) {
112+ this . cache . delete ( key ) ;
113+ }
114+ }
115+ }
116+
109117 private async initialize ( ) : Promise < void > {
110118 // Load from persistent storage first (instant hydration)
111119 if ( ! this . config . skipStorage && this . storage ) {
@@ -304,6 +312,10 @@ export class CoreFlagsManager implements FlagsManager {
304312 cacheEntry : createCacheEntry ( result , ttl , staleTime ) ,
305313 } ) ) ;
306314
315+ this . removeStaleKeys (
316+ new Set ( flagCacheEntries . map ( ( { cacheKey } ) => cacheKey ) )
317+ ) ;
318+
307319 for ( const { cacheKey, cacheEntry } of flagCacheEntries ) {
308320 this . cache . set ( cacheKey , cacheEntry ) ;
309321 }
You can’t perform that action at this time.
0 commit comments