Skip to content

Commit e8a7400

Browse files
committed
Treat cache as promise
1 parent 63daf60 commit e8a7400

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/shared/akamai-edgeworker-sdk/src/api/LDClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class LDClient extends LDClientImpl {
3434
this._cacheableStoreProvider = storeProvider;
3535
}
3636

37+
override initialized(): boolean {
38+
return true;
39+
}
40+
3741
override waitForInitialization(): Promise<LDClientType> {
3842
// we need to resolve the promise immediately because Akamai's runtime doesnt
3943
// have a setimeout so everything executes synchronously.

packages/shared/akamai-edgeworker-sdk/src/featureStore/cacheableStoreProvider.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { EdgeProvider } from '.';
2222
* - 10 for enterprise
2323
*/
2424
export default class CacheableStoreProvider implements EdgeProvider {
25-
cache: string | null | undefined;
25+
cache: Promise<string | null | undefined> | null | undefined;
2626
cachedAt: number | undefined;
2727

2828
constructor(
@@ -38,10 +38,7 @@ export default class CacheableStoreProvider implements EdgeProvider {
3838
*/
3939
async get(rootKey: string): Promise<string | null | undefined> {
4040
if (!this._isCacheValid()) {
41-
const updatedResults = await this._edgeProvider.get(rootKey);
42-
if (updatedResults !== undefined) {
43-
this.cache = updatedResults;
44-
}
41+
this.cache = this._edgeProvider.get(rootKey);
4542
this.cachedAt = Date.now();
4643
}
4744

0 commit comments

Comments
 (0)