import{isTtlCorrect as n}from"../../../utils/is-ttl-correct.js";import{CacheLocalRepository as i}from"../repositories/cache-local-repository.js";class a{static#e;#t;constructor(t){this.#t=t}static async#a(t){const e=await i.getInstance(t),s=new a(e);a.#e=s}static async getInstance(t){return t.removeExisting===void 0&&(t.removeExisting=!1),a.#e||await a.#a(t),a.#e}async get(t){const e=await this.#t.get(t.key,t.namespace);return e?e.value:null}async set(t){if(!n(t.ttlInSeconds))throw new Error("TTL must be null or a positive number");return await this.#t.set(t)}async delete(t,e){return await this.#t.delete(t,e)}async deleteByNamespace(t){return await this.#t.deleteByNamespace(t)}async clear(){return await this.#t.clearAll()}}export{a as CacheService};
