Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@resolid/cache-manager-sqlite

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@resolid/cache-manager-sqlite - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

4

dist/index.js
import O from 'better-sqlite3';
var h=()=>new Date().getTime(),b=i=>{let u=i?.isCacheable??(t=>t!=null),s=new O(i.sqliteFile),a=i.cacheTableName;s.exec(`
var h=()=>new Date().getTime(),b=i=>{let u=i?.isCacheable??(t=>t!==void 0),s=new O(i.sqliteFile),a=i.cacheTableName;s.exec(`
CREATE TABLE IF NOT EXISTS ${a} (

@@ -11,4 +11,4 @@ 'cacheKey' TEXT PRIMARY KEY,

CREATE INDEX IF NOT EXISTS idx_expired_caches ON ${a}(expiredAt);
`);let E=s.prepare(`SELECT * FROM ${a} WHERE cacheKey = ?`),g=s.prepare(`INSERT OR REPLACE INTO ${a}(cacheKey, cacheData, createdAt, expiredAt) VALUES (?, ?, ?, ?)`),y=s.prepare(`DELETE FROM ${a} WHERE cacheKey = ?`),S=s.prepare(`SELECT cacheKey FROM ${a} WHERE cacheKey LIKE ?`),T=s.prepare(`DELETE FROM ${a}`),d=(...t)=>{let r=h();return s.transaction(e=>e.map(c=>E.get(c)).filter(c=>c!=null&&(c.expiredAt==-1||c.expiredAt>r)))(t)},m=(...t)=>{s.transaction(n=>{for(let e of n)y.run(e);})(t);},p=(t,r)=>{let n=r??i?.ttl,e=h(),c=n!=null&&n!=0?e+n:-1;s.transaction((f,A,C)=>{for(let l of f){if(!u(l[1]))throw new Error(`no cacheable value ${JSON.stringify(l[1])}`);g.run(l[0],JSON.stringify(l[1]),A,C);}})(t,e,c);};return {del(t){return new Promise((r,n)=>{try{m(t),r();}catch(e){n(e);}})},get(t){return new Promise((r,n)=>{try{let e=d(t);e.length==0?r(void 0):r(JSON.parse(e[0].cacheData));}catch(e){n(e);}})},keys(t){return new Promise((r,n)=>{try{let e=S.all(t?.replace("*","%")??"%").map(c=>c.cacheKey);r(e);}catch(e){n(e);}})},mdel(...t){return new Promise((r,n)=>{try{m(...t),r();}catch(e){n(e);}})},mget(...t){return new Promise((r,n)=>{try{let e=d(...t).map(o=>JSON.parse(o.cacheData)),c=t.length-e.length;r(c?e.concat(Array(c).fill(void 0)):e);}catch(e){n(e);}})},mset(t,r){return new Promise((n,e)=>{try{p(t,r),n();}catch(c){e(c);}})},reset(){return new Promise((t,r)=>{try{T.run(),t();}catch(n){r(n);}})},set(t,r,n){return new Promise((e,c)=>{try{p([[t,r]],n),e();}catch(o){c(o);}})},ttl(t){return new Promise((r,n)=>{try{let e=d(t);e.length==0?r(-2):r(e[0].expiredAt==-1?-1:e[0].expiredAt-h());}catch(e){n(e);}})},get client(){return s}}};
`);let E=s.prepare(`SELECT * FROM ${a} WHERE cacheKey = ?`),g=s.prepare(`INSERT OR REPLACE INTO ${a}(cacheKey, cacheData, createdAt, expiredAt) VALUES (?, ?, ?, ?)`),y=s.prepare(`DELETE FROM ${a} WHERE cacheKey = ?`),S=s.prepare(`SELECT cacheKey FROM ${a} WHERE cacheKey LIKE ?`),T=s.prepare(`DELETE FROM ${a}`),d=(...t)=>{let r=h();return s.transaction(e=>e.map(c=>E.get(c)).filter(c=>c!==void 0&&(c.expiredAt==-1||c.expiredAt>r)))(t)},m=(...t)=>{s.transaction(n=>{for(let e of n)y.run(e);})(t);},p=(t,r)=>{let n=r??i?.ttl,e=h(),c=n!=null&&n!=0?e+n:-1;s.transaction((f,A,C)=>{for(let l of f){if(!u(l[1]))throw new Error(`no cacheable value ${JSON.stringify(l[1])}`);g.run(l[0],JSON.stringify(l[1]),A,C);}})(t,e,c);};return {del(t){return new Promise((r,n)=>{try{m(t),r();}catch(e){n(e);}})},get(t){return new Promise((r,n)=>{try{let e=d(t);e.length==0?r(void 0):r(JSON.parse(e[0].cacheData));}catch(e){n(e);}})},keys(t){return new Promise((r,n)=>{try{let e=S.all(t?.replace("*","%")??"%").map(c=>c.cacheKey);r(e);}catch(e){n(e);}})},mdel(...t){return new Promise((r,n)=>{try{m(...t),r();}catch(e){n(e);}})},mget(...t){return new Promise((r,n)=>{try{let e=d(...t).map(o=>JSON.parse(o.cacheData)),c=t.length-e.length;r(c?e.concat(Array(c).fill(void 0)):e);}catch(e){n(e);}})},mset(t,r){return new Promise((n,e)=>{try{p(t,r),n();}catch(c){e(c);}})},reset(){return new Promise((t,r)=>{try{T.run(),t();}catch(n){r(n);}})},set(t,r,n){return new Promise((e,c)=>{try{p([[t,r]],n),e();}catch(o){c(o);}})},ttl(t){return new Promise((r,n)=>{try{let e=d(t);e.length==0?r(-2):r(e[0].expiredAt==-1?-1:e[0].expiredAt-h());}catch(e){n(e);}})},get client(){return s}}};
export { b as sqliteStore };
{
"name": "@resolid/cache-manager-sqlite",
"version": "5.1.0",
"version": "5.1.1",
"description": "A new SQLite store for cache-manager",

@@ -5,0 +5,0 @@ "keywords": ["cache-manager", "sqlite", "better-sqlite3"],

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc