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.1 to 5.1.2

1

dist/index.d.ts

@@ -7,2 +7,3 @@ import Database from 'better-sqlite3';

cacheTableName: string;
enableWALMode?: boolean;
} & Config;

@@ -9,0 +10,0 @@ type SqliteStore = Store & {

12

dist/index.js

@@ -1,5 +0,5 @@

import O from 'better-sqlite3';
import T from 'better-sqlite3';
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} (
var d=()=>new Date().getTime(),O=o=>{let p=o?.isCacheable??(t=>t!==void 0),E=o?.enableWALMode??!0,i=new T(o.sqliteFile);E&&i.pragma("journal_mode = WAL");let s=o.cacheTableName;i.exec(`
CREATE TABLE IF NOT EXISTS ${s} (
'cacheKey' TEXT PRIMARY KEY,

@@ -10,5 +10,5 @@ 'cacheData' TEXT,

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

@@ -35,15 +35,15 @@ "keywords": ["cache-manager", "sqlite", "better-sqlite3"],

"devDependencies": {
"@biomejs/biome": "^1.7.1",
"@biomejs/biome": "^1.7.2",
"@faker-js/faker": "^8.4.1",
"@types/better-sqlite3": "^7.6.10",
"@vitest/ui": "^1.5.2",
"@vitest/ui": "^1.6.0",
"better-sqlite3": "^9.6.0",
"cache-manager": "^5.5.1",
"cache-manager": "^5.5.2",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vitest": "^1.5.2"
"vitest": "^1.6.0"
},
"peerDependencies": {
"better-sqlite3": "^9.6.0",
"cache-manager": "^5.5.1"
"cache-manager": "^5.5.2"
},

@@ -50,0 +50,0 @@ "repository": {

@@ -33,3 +33,3 @@ # SQLite store for cache manager

// On disk cache on employees table
// On disk cache on caches table
const sqliteStoreCache = cacheManager.caching(sqliteStore({sqliteFile: join(process.cwd(), 'cache.sqlite3'), cacheTableName: 'caches'}))

@@ -46,2 +46,2 @@ ```

![JetBrain](.github/assets/jetbrain-logo.svg)
![JetBrain](.github/assets/jetbrain-logo.svg)

Sorry, the diff of this file is not supported yet

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