From 7e22a3074e964a5c6915f1002cc5cb281ea75817 Mon Sep 17 00:00:00 2001 From: ynwd <10122431+ynwd@users.noreply.github.com> Date: Mon, 2 Dec 2024 06:44:21 +0700 Subject: [PATCH] chore: update syncMap --- core/map/mod.ts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/core/map/mod.ts b/core/map/mod.ts index 244d2e88..f2eff268 100644 --- a/core/map/mod.ts +++ b/core/map/mod.ts @@ -177,21 +177,18 @@ export class Store { } 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; - 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; + if (!map) return; + this.map = map; + this.cleanUpExpiredEntries(); + await this.commit(); } private cleanUpExpiredEntries(): void {