Skip to content

Commit 9b8d36a

Browse files
Clear segments and largeSegments caches
1 parent 6605bfc commit 9b8d36a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/storages/inLocalStorage/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ import { shouldRecordTelemetry, TelemetryCacheInMemory } from '../inMemory/Telem
1414
import { UniqueKeysCacheInMemoryCS } from '../inMemory/UniqueKeysCacheInMemoryCS';
1515
import { getMatching } from '../../utils/key';
1616
import { validateCache } from './validateCache';
17-
18-
export interface InLocalStorageOptions {
19-
prefix?: string
20-
}
17+
import SplitIO from '../../../types/splitio';
2118

2219
/**
2320
* InLocal storage factory for standalone client-side SplitFactory
2421
*/
25-
export function InLocalStorage(options: InLocalStorageOptions = {}): IStorageSyncFactory {
22+
export function InLocalStorage(options: SplitIO.InLocalStorageOptions = {}): IStorageSyncFactory {
2623

2724
const prefix = validatePrefix(options.prefix);
2825

@@ -53,7 +50,7 @@ export function InLocalStorage(options: InLocalStorageOptions = {}): IStorageSyn
5350
uniqueKeys: impressionsMode === NONE ? new UniqueKeysCacheInMemoryCS() : undefined,
5451

5552
validateCache() {
56-
return validateCache(settings, keys, splits);
53+
return validateCache(settings, keys, splits, segments, largeSegments);
5754
},
5855

5956
destroy() { },

src/storages/inLocalStorage/validateCache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { isNaNNumber } from '../../utils/lang';
44
import { getStorageHash } from '../KeyBuilder';
55
import { LOG_PREFIX } from './constants';
66
import type { SplitsCacheInLocal } from './SplitsCacheInLocal';
7+
import type { MySegmentsCacheInLocal } from './MySegmentsCacheInLocal';
78
import { KeyBuilderCS } from '../KeyBuilderCS';
89

910
function validateExpiration(settings: ISettings, keys: KeyBuilderCS) {
@@ -38,10 +39,12 @@ function validateExpiration(settings: ISettings, keys: KeyBuilderCS) {
3839
* - it has expired, i.e., its `lastUpdated` timestamp is older than the given `expirationTimestamp`
3940
* - hash has changed, i.e., the SDK key, flags filter criteria or flags spec version was modified
4041
*/
41-
export function validateCache(settings: ISettings, keys: KeyBuilderCS, splits: SplitsCacheInLocal): boolean {
42+
export function validateCache(settings: ISettings, keys: KeyBuilderCS, splits: SplitsCacheInLocal, segments: MySegmentsCacheInLocal, largeSegments: MySegmentsCacheInLocal): boolean {
4243

4344
if (validateExpiration(settings, keys)) {
4445
splits.clear();
46+
segments.clear();
47+
largeSegments.clear();
4548
}
4649

4750
// Check if the cache is ready

0 commit comments

Comments
 (0)