Skip to content

Commit fc6ae41

Browse files
committed
feat: get and remove all keys
1 parent 0ec24bb commit fc6ae41

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

electron/main/store/store.service.ts

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class StoreServiceImpl implements StoreService {
1818
this.cacheService = new DiskCacheServiceImpl(options);
1919
}
2020

21+
public async keys(): Promise<Array<string>> {
22+
return Object.keys(await this.cacheService.readCache());
23+
}
24+
2125
public async get<T>(key: string): Promise<T | undefined> {
2226
const storedValue = await this.cacheService.get<StoredValue<T>>(key);
2327

@@ -70,6 +74,10 @@ class StoreServiceImpl implements StoreService {
7074
public async remove(key: string): Promise<void> {
7175
await this.cacheService.remove(key);
7276
}
77+
78+
public async removeAll(): Promise<void> {
79+
await this.cacheService.clear();
80+
}
7381
}
7482

7583
// There is exactly one store instance so that it's

electron/main/store/store.types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export interface StoreSetOptions {
1717
}
1818

1919
export interface StoreService {
20+
keys(): Promise<Array<string>>;
2021
get<T>(key: string): Promise<T | undefined>;
2122
set<T>(key: string, value: T, options?: StoreSetOptions): Promise<void>;
2223
remove(key: string): Promise<void>;
24+
removeAll(): Promise<void>;
2325
}

0 commit comments

Comments
 (0)