Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear Global SDK keys cache #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/StatsigOnPrem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ export default class StatsigOnPrem implements StatsigInterface {
): Promise<void> {
await this.store.assignTargetAppsToSDKKey(targetApps, sdkKey);
await this.cache.clearSpecs(sdkKey);
await this.cache.clearGlobalSDKKeys();
}

public async removeTargetAppsFromSDKKey(
Expand All @@ -495,11 +496,13 @@ export default class StatsigOnPrem implements StatsigInterface {
): Promise<void> {
await this.store.removeTargetAppsFromSDKKey(targetApps, sdkKey);
await this.cache.clearSpecs(sdkKey);
await this.cache.clearGlobalSDKKeys();
}

public async clearTargetAppsFromSDKKey(sdkKey: string): Promise<void> {
await this.store.clearTargetAppsFromSDKKey(sdkKey);
await this.cache.clearSpecs(sdkKey);
await this.cache.clearGlobalSDKKeys();
}

public async getTargetAppNames(
Expand All @@ -516,12 +519,14 @@ export default class StatsigOnPrem implements StatsigInterface {
public async registerSDKKey(sdkKey: string): Promise<void> {
const sdkKeys = await this.store.addSDKKey(sdkKey);
await this.cache.cacheSDKKeys(sdkKeys);
await this.cache.clearGlobalSDKKeys();
}

public async deactivateSDKKey(sdkKey: string): Promise<void> {
const sdkKeys = await this.store.removeSDKKey(sdkKey);
await this.cache.cacheSDKKeys(sdkKeys);
await this.cache.clearSpecs(sdkKey);
await this.cache.clearGlobalSDKKeys();
}

public async getRegisteredSDKKeys(): Promise<Set<string>> {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/CacheHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default class CacheHandler {
return await this.cache.keys.getGlobal();
}

public async clearGlobalSDKKeys(): Promise<void> {
await this.cache.keys.clearGlobal();
}

public async clearSDKKeys(): Promise<void> {
await this.cache.keys.clear();
await this.cache.keys.clearGlobal();
Expand Down