Skip to content

Commit

Permalink
chore: update syncMap
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Dec 1, 2024
1 parent 44e9d8c commit 7e22a30
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions core/map/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,18 @@ export class Store<K extends string | number | symbol, V> {
}

public async syncMap() {
if (this.map.size === 0 && this.options) {
const key = this.options.namespace
? [this.options.key, ...this.options.namespace]
: [this.options.key];
const res = await kv.get(key);

// deno-lint-ignore no-explicit-any
const map = res.value as Map<any, any>;
if (!map) return false;
this.map = map;
this.cleanUpExpiredEntries();
await this.commit();
}

return true;
if (!this.options) return;
const key = this.options.namespace
? [this.options.key, ...this.options.namespace]
: [this.options.key];
const res = await kv.get(key);

// deno-lint-ignore no-explicit-any
const map = res.value as Map<any, any>;
if (!map) return;
this.map = map;
this.cleanUpExpiredEntries();
await this.commit();
}

private cleanUpExpiredEntries(): void {
Expand Down

0 comments on commit 7e22a30

Please sign in to comment.