UNPKG

cachified-redis-json-adapter

Version:
3 lines (2 loc) 540 B
var i=Symbol(),l=Symbol();function o(e){return(typeof e.swr>"u"?e.swv:e.swr)||null}function s(e){return e?e.ttl===null?1/0:(e.ttl||0)+(o(e)||0):0}var u=Symbol();function d(e){return{name:e.name||"RedisJson",delete(t){return e.json.del(t)},async set(t,a){let r=s(a?.metadata),n=a?.metadata?.createdTime,c=await e.json.set(t,"$",a);return r>0&&r<1/0&&typeof n=="number"&&await e.expireAt(t,Math.ceil((r+n)/1e3)),c},async get(t){let a=await e.json.get(t);return a??null}}}export{d as redisJsonCacheAdapter}; //# sourceMappingURL=index.mjs.map