import{isTtlCorrect as a}from"../../../utils/is-ttl-correct.js";import{CacheRepository as i}from"../repositories/cache-repository.js";class s{static#e;#t;constructor(t){this.#t=t}static async#s(t){const e=await i.getInstance(t),n=new s(e);s.#e=n}static async getInstance(t){return t.removeExisting===void 0&&(t.removeExisting=!1),s.#e||await s.#s(t),s.#e}async get(t){const e=await this.#t.get(t.key,t.namespace);return e?e.value:null}async set(t){if(!a(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{s as CacheService};
