Comparing version 6.0.0-canary.0 to 6.0.0-canary.1
@@ -1,1 +0,1 @@ | ||
var k=Object.create;var w=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var E=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),G=(r,e)=>{for(var a in e)w(r,a,{get:e[a],enumerable:!0})},S=(r,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of _(e))!N.call(r,c)&&c!==a&&w(r,c,{get:()=>e[c],enumerable:!(i=F(e,c))||i.enumerable});return r};var K=(r,e,a)=>(a=r!=null?k(I(r)):{},S(e||!r||!r.__esModule?w(a,"default",{value:r,enumerable:!0}):a,r)),V=r=>S(w({},"__esModule",{value:!0}),r);var R=E((we,C)=>{var h=1e3,M=h*60,p=M*60,m=p*24,J=m*7,L=m*365.25;C.exports=function(r,e){e=e||{};var a=typeof r;if(a==="string"&&r.length>0)return H(r);if(a==="number"&&isFinite(r))return e.long?j(r):P(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function H(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!!e){var a=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return a*L;case"weeks":case"week":case"w":return a*J;case"days":case"day":case"d":return a*m;case"hours":case"hour":case"hrs":case"hr":case"h":return a*p;case"minutes":case"minute":case"mins":case"min":case"m":return a*M;case"seconds":case"second":case"secs":case"sec":case"s":return a*h;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function P(r){var e=Math.abs(r);return e>=m?Math.round(r/m)+"d":e>=p?Math.round(r/p)+"h":e>=M?Math.round(r/M)+"m":e>=h?Math.round(r/h)+"s":r+"ms"}function j(r){var e=Math.abs(r);return e>=m?A(r,e,m,"day"):e>=p?A(r,e,p,"hour"):e>=M?A(r,e,M,"minute"):e>=h?A(r,e,h,"second"):r+" ms"}function A(r,e,a,i){var c=e>=a*1.5;return Math.round(r/a)+" "+i+(c?"s":"")}});var q={};G(q,{MemoryCache:()=>B});module.exports=V(q);var x=K(R()),D=require("fs/promises");var v=require("crypto"),z=async(r,e)=>{let a=(0,v.randomBytes)(16),i=(0,v.createCipheriv)("aes-256-cbc",Buffer.from(e),a),c=Buffer.concat([i.update(r),i.final()]);return`${a.toString("hex")}:${c.toString("hex")}`};var O=require("crypto"),$=async(r,e)=>{let a=r.split(":"),i=Buffer.from(a.shift(),"hex"),c=Buffer.from(a.join(":"),"hex"),f=(0,O.createDecipheriv)("aes-256-cbc",Buffer.from(e),i);return Buffer.concat([f.update(c),f.final()]).toString()};var Y=(r={})=>{let e=new Map,a={},i,c=0,f=typeof r.maxAge=="number"?r.maxAge*1e3:typeof r.maxAge=="string"?(0,x.default)(r.maxAge):6e5,l=r.maxAmount??1e4,g=async()=>{for(let[t,o]of e)Date.now()-o.age>f&&e.delete(t)},b=async()=>{let t=0,o;for(let[n,s]of e)s.age>t&&(t=s.age,o=n);o&&e.delete(o)};return{set:async(t,o,n)=>{if(a.set&&await a.set(t,o,n),e.has(t))return;f!==1/0&&await g(),e.size>l&&await b();let s={value:o,age:Date.now(),...typeof n=="string"?{maxAge:(0,x.default)(n)}:typeof n=="number"&&{maxAge:n*1e3}};return e.set(t,s),i={key:t,...s},{key:t,...s}},setMany:async t=>{a.setMany&&await a.setMany(t),f!==1/0&&await g();let o=[];for(let n of t){let s=n[0],d=n[1],u=n[2];if(e.has(s)){o.push(void 0);continue}let y={value:d,age:Date.now(),...typeof u=="string"?{maxAge:(0,x.default)(u)}:typeof u=="number"&&{maxAge:u*1e3}};e.size>l&&await b(),e.set(s,y),i={key:s,...y},o.push({key:s,...y})}return o},get:async(t,o={})=>{a.get&&await a.get(t,o);let n=e.get(t);if(!!n){if(o.validate!==!1&&(n.maxAge?Date.now()-n.age>n.maxAge:Date.now()-n.age>f)){e.delete(t);return}return o.delete&&e.delete(t),{key:t,...n}}},getMany:async(t,o={})=>{a.getMany&&await a.getMany(t,o);let n=[];for(let s of t){let d=e.get(s);if(!d){n=[...n,void 0];continue}if(o.validate!==!1&&(d.maxAge?Date.now()-d.age>d.maxAge:Date.now()-d.age>f)){e.delete(s),n=[...n,void 0];continue}o.delete&&e.delete(s),n=[...n,{key:s,...d}]}return o.reverse?n.reverse():n},update:async(t,o,n)=>{a.update&&await a.update(t,o,n??{});let s=e.get(t);if(!s)return;let d={value:o,age:n&&n.updateAge?Date.now():s.age,...s.maxAge&&{maxAge:s.maxAge}};e.set(t,d),i={key:t,...d}},updateMany:async(t,o)=>{a.updateMany&&await a.updateMany(t,o??{});for(let n of t){let s=e.get(n[0]);if(!s)continue;let d={value:n[1],age:o&&o.updateAge?Date.now():s.age,...s.maxAge&&{maxAge:s.maxAge}};e.set(n[0],d),i={key:n[0],...d}}},delete:async t=>{a.delete&&await a.delete(t),e.delete(t)},deleteMany:async t=>{a.deleteMany&&await a.deleteMany(t),t.length===0&&e.clear();for(let o of t)e.delete(o)},has:async t=>(a.has&&await a.has(t),e.has(t)),size:async()=>(a.size&&await a.size(),e.size),keys:async()=>(a.keys&&await a.keys(),[...e.keys()]),values:async()=>{a.values&&await a.values();let t=[];for(let[o,n]of e)t=[...t,n.value];return t},clear:async()=>(a.clear&&await a.clear(),await g()),memory:async()=>{a.memory&&await a.memory();let t=[...e.keys()].toString()+[...e.values()].toString(),o=Buffer.from(t);return Buffer.byteLength(o)},recent:async()=>(a.recent&&await a.recent(),i),maxAge:async t=>(a.maxAge&&await a.maxAge(t),t&&(f=typeof t=="number"?t*1e3:typeof t=="string"?(0,x.default)(t):6e5,await g()),f),maxAmount:async t=>(a.maxAmount&&await a.maxAmount(t),t&&(l=t??1e4,await g()),l),newest:async()=>{if(a.newest&&await a.newest(),e.size===0)return;let t=0,o;for(let[n,s]of e)s.age>t&&(t=s.age,o={key:n,...s});return o},oldest:async()=>{if(a.oldest&&await a.oldest(),e.size===0)return;let t=0,o;for(let[n,s]of e)(t===0||s.age<t)&&(t=s.age,o={key:n,...s});return o},on:async(t,o)=>{a[t]=o},dump:async()=>{if(a.dump&&await a.dump(),e.size===0)return[];let t=[];for(let[o,n]of e)t=[...t,{key:o,...n}];return t},import:async(t,o)=>{try{let n=await(0,D.readFile)(t,{encoding:"utf-8"}),s=await $(n,o),d=JSON.parse(s);for(let u of d.records)e.set(u.key,{value:u.value,age:u.age,...u.maxAge&&{maxAge:u.maxAge}});return!0}catch(n){return console.log(n),!1}},export:async(t,o)=>{try{let n=[];for(let[T,U]of e)n=[...n,{key:T,...U}];let s=new Date,d={records:n,metadata:{exportedAt:s,version:5}},u=Math.floor(Math.random()*1e8),y=`${t}/${s.getUTCMonth()<10?"0":""}${s.getUTCMonth()+1}-${s.getUTCDate()<10?"0":""}${s.getUTCDate()}-${s.getUTCFullYear()} #${u}.cachu`;return await(0,D.writeFile)(y,await z(JSON.stringify(d),o),{encoding:"utf-8"}),{path:y,success:!0,exportedAt:s,version:5}}catch{return{path:void 0,success:!1,exportedAt:void 0,version:5}}}}},B=Y;0&&(module.exports={MemoryCache}); | ||
var x=Object.create;var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var P=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w(e))!L.call(s,a)&&a!==t&&f(s,a,{get:()=>e[a],enumerable:!(n=A(e,a))||n.enumerable});return s};var v=(s,e,t)=>(t=s!=null?x(g(s)):{},P(e||!s||!s.__esModule?f(t,"default",{value:s,enumerable:!0}):t,s));var m=M((F,b)=>{var i=1e3,o=i*60,u=o*60,r=u*24,k=r*7,D=r*365.25;b.exports=function(s,e){e=e||{};var t=typeof s;if(t==="string"&&s.length>0)return z(s);if(t==="number"&&isFinite(s))return e.long?O(s):E(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))};function z(s){if(s=String(s),!(s.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!!e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*D;case"weeks":case"week":case"w":return t*k;case"days":case"day":case"d":return t*r;case"hours":case"hour":case"hrs":case"hr":case"h":return t*u;case"minutes":case"minute":case"mins":case"min":case"m":return t*o;case"seconds":case"second":case"secs":case"sec":case"s":return t*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function E(s){var e=Math.abs(s);return e>=r?Math.round(s/r)+"d":e>=u?Math.round(s/u)+"h":e>=o?Math.round(s/o)+"m":e>=i?Math.round(s/i)+"s":s+"ms"}function O(s){var e=Math.abs(s);return e>=r?_(s,e,r,"day"):e>=u?_(s,e,u,"hour"):e>=o?_(s,e,o,"minute"):e>=i?_(s,e,i,"second"):s+" ms"}function _(s,e,t,n){var a=e>=t*1.5;return Math.round(s/t)+" "+n+(a?"s":"")}});var c=v(m(),1);var y=v(m(),1),d=class{__eventListeners;__recentEntry;__maxAge;__maxAmount;__webhook;__autoclear;constructor(e){e=e??{},this.__eventListeners={},this.__maxAge=typeof e.maxAge=="number"?e.maxAge*1e3:typeof e.maxAge=="string"?(0,y.default)(e.maxAge):(0,y.default)("10m"),this.__maxAmount=e.maxAmount??1e4,this.__autoclear=e.autoclear??!1,typeof e.webhook=="string"&&(this.__webhook=e.webhook)}},p=d;var l=class extends p{store;consumedMemory;constructor(e){super(e),this.store=new Map,this.consumedMemory=0}async deleteOutdated(e){}async set(e,t,n){if(this.__eventListeners.set&&await this.__eventListeners.set(e,t,n),this.store.has(e))return;this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated(),this.__autoclear&&this.store.size+1>this.__maxAmount&&await this.deleteOutdated(1);let a={value:t,...typeof n=="string"?{expiresAt:Date.now()+(0,c.default)(n)}:typeof n=="number"?{expiresAt:Date.now()+n*1e3}:this.__maxAge!==1/0&&{expiresAt:Date.now()+this.__maxAge}};this.store.set(e,a),this.__recentEntry={key:e,...a}}async setMany(e){this.__eventListeners.setMany&&await this.__eventListeners.setMany(e),this.__autoclear&&this.__maxAge!==1/0&&await this.deleteOutdated(),this.__autoclear&&this.store.size+e.length>this.__maxAmount&&await this.deleteOutdated(this.store.size+e.length-this.__maxAmount);for(let t of e){if(this.store.has(t[0]))continue;let n={value:t[1],...typeof t[2]=="string"?{expiresAt:Date.now()+(0,c.default)(t[2])}:typeof t[2]=="number"?{expiresAt:Date.now()+t[2]*1e3}:this.__maxAge!==1/0&&{expiresAt:Date.now()+this.__maxAge}};this.store.set(t[0],n),this.__recentEntry={key:t[0],...n}}}async get(e,t){t=t??{},this.__eventListeners.get&&await this.__eventListeners.get(e,t);let n=this.store.get(e);if(!!n){if(t.validate&&n.expiresAt&&Date.now()>=n.expiresAt){this.store.delete(e);return}return t.delete&&this.store.delete(e),n.value}}async getMany(e,t){t=t??{},this.__eventListeners.getMany&&await this.__eventListeners.getMany(e,t);let n=[];for(let a of e){let h=this.store.get(a);if(!h){n=[...n,void 0];continue}if(t.validate&&h.expiresAt&&Date.now()>=h.expiresAt){this.store.delete(a),n=[...n,void 0];continue}t.delete&&this.store.delete(a),n=[...n,h.value]}return n}async update(e,t){this.__eventListeners.update&&await this.__eventListeners.update(e,t);let n=this.store.get(e);if(!n)return;let a={value:t,...n.expiresAt&&{expiresAt:n.expiresAt}};this.store.set(e,a),this.__recentEntry={key:e,...a}}async updateMany(e){this.__eventListeners.updateMany&&await this.__eventListeners.updateMany(e);for(let t of e){let n=this.store.get(t[0]);if(!n)continue;let a={value:t[1],...n.expiresAt&&{expiresAt:n.expiresAt}};this.store.set(t[0],a),this.__recentEntry={key:t[0],...a}}}async delete(e){this.__eventListeners.delete&&await this.__eventListeners.delete(e),this.store.delete(e)}async deleteMany(e){this.__eventListeners.deleteMany&&await this.__eventListeners.deleteMany(e),e.length===0&&this.store.clear();for(let t of e)this.store.delete(t)}async has(e){return this.__eventListeners.has&&await this.__eventListeners.has(e),this.store.has(e)}async size(){return this.__eventListeners.size&&await this.__eventListeners.size(),this.store.size}async keys(){return this.__eventListeners.keys&&await this.__eventListeners.keys(),[...this.store.keys()]}async values(){this.__eventListeners.values&&await this.__eventListeners.values();let e=[];for(let[t,n]of this.store)e=[...e,n.value];return e}async clear(){this.__eventListeners.clear&&await this.__eventListeners.clear();for(let[e,t]of this.store)t.expiresAt&&Date.now()>=t.expiresAt&&this.store.delete(e)}async memory(){this.__eventListeners.memory&&await this.__eventListeners.memory();let e=[...this.store.keys()].toString()+[...this.store.values()].toString(),t=Buffer.from(e);return Buffer.byteLength(t)}async recent(){return this.__eventListeners.recent&&await this.__eventListeners.recent(),this.__recentEntry}async maxAge(e){return this.__eventListeners.maxAge&&await this.__eventListeners.maxAge(),e?(this.__maxAge=typeof e=="number"?e*1e3:(0,c.default)(e),this.__maxAge):this.__maxAge}async maxAmount(e){return this.__eventListeners.maxAmount&&await this.__eventListeners.maxAmount(),e?(this.__maxAmount=e,e):this.__maxAmount}async each(e){this.__eventListeners.each&&await this.__eventListeners.each();for(let[t,n]of this.store)await e(t,n)}async on(){this.__eventListeners.on&&await this.__eventListeners.on()}},S=l;export{S as MemoryCache}; |
{ | ||
"name": "cachu", | ||
"version": "6.0.0-canary.0", | ||
"description": "🦝 Simple, Minimalistic KV Cache", | ||
"types": "./types/index.d.ts", | ||
"main": "./dist/index.js", | ||
"version": "6.0.0-canary.1", | ||
"description": "A modern and simple key-value cache for Node.js.", | ||
"types": "types/index.d.ts", | ||
"exports": "./dist/index.js", | ||
"scripts": { | ||
"build": "esbuild src/index.ts --bundle --minify --format=cjs --platform=node --outfile=dist/index.js", | ||
"publish:canary": "npm run build && npm publish --tag canary", | ||
"build": "rimraf dist && rimraf types && tsc && esbuild src/index.ts --bundle --minify --format=esm --legal-comments=none --platform=node --outfile=dist/index.js", | ||
"publish:canary": "npm run build && npm version prerelease --preid=canary && npm publish --tag canary", | ||
"publish:patch": "npm run build && npm version patch && npm publish", | ||
"publish:minor": "npm run build && npm version minor && npm publish", | ||
"publish:major": "npm run build && npm version major && npm publish", | ||
"test": "jest --detectOpenHandles" | ||
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js" | ||
}, | ||
"funding": { | ||
"type": "individual", | ||
"url": "https://ko-fi.com/azury" | ||
}, | ||
"repository": { | ||
@@ -26,3 +22,5 @@ "type": "git", | ||
"cache", | ||
"production-ready", | ||
"asynchronous", | ||
"modules", | ||
"simple" | ||
@@ -39,11 +37,20 @@ ], | ||
"@types/ms": "^0.7.31", | ||
"esbuild": "^0.14.39", | ||
"@types/node": "^17.0.40", | ||
"@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"@typescript-eslint/parser": "^5.27.0", | ||
"esbuild": "^0.14.42", | ||
"eslint": "^8.17.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-unused-imports": "^2.0.0", | ||
"jest": "^28.1.0", | ||
"ms": "^2.1.3", | ||
"ts-jest": "^28.0.2", | ||
"typescript": "^4.6.4" | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^28.0.3", | ||
"typescript": "^4.7.2" | ||
}, | ||
"engines": { | ||
"node": ">=16", | ||
"node": ">=18", | ||
"npm": ">=8" | ||
} | ||
}, | ||
"type": "module" | ||
} |
# cachu | ||
> 👀 **v6** goes public on August 1st and it'll come with a dashboard for a visual insight into your cachu instance. Of course, the feature will be fully optional. | ||
**Simple, minimalistic key-value cache, created by [Azury](https://azury.dev).** | ||
- fully asynchronous | ||
- small n' easy | ||
- zero dependencies | ||
- `fully asynchronous` | ||
- `small n' easy` | ||
- `zero dependencies` | ||
@@ -15,7 +13,8 @@ ## Setup | ||
Install **cachu** using your favorite package manager. | ||
```bash | ||
# Install the latest (stable) release. | ||
npm i cachu | ||
```sh-session | ||
npm i cachu | ||
yarn add cachu | ||
# Try out new feature before they hit our stable release. | ||
npm i cachu@canary | ||
``` | ||
@@ -25,4 +24,2 @@ | ||
Just create a new cache, it's as easy as that! | ||
```js | ||
@@ -32,9 +29,8 @@ import { MemoryCache } from 'cachu' | ||
(async () => { | ||
const cache = MemoryCache() | ||
const cache = new MemoryCache() | ||
// add a new record | ||
await cache.set('one', 'Hello Github') | ||
// Set a new entry. | ||
await cache.set('one', 'Hello World') | ||
// retrieve the value of a record | ||
const { value } = await cache.get('one') | ||
console.log(await cache.get('one')) // Gives out "Hello World" on console. | ||
})() | ||
@@ -45,3 +41,5 @@ ``` | ||
- [`BigCache`](/guide/caches/BigCache.md) | ||
- [`MemoryCache`](/guide/caches/MemoryCache.md) | ||
- [`DiskCache`](/guide/caches/DiskCache.md) | ||
@@ -48,0 +46,0 @@ ## API |
@@ -1,152 +0,44 @@ | ||
declare type Key = any | ||
declare type Value = any | ||
declare type Record = { | ||
key: Key, | ||
value: Value, | ||
age: number, | ||
maxAge?: number | ||
import { Action } from '../types'; | ||
import Cache from './Cache'; | ||
declare class MemoryCache extends Cache { | ||
private store; | ||
private consumedMemory; | ||
constructor(config?: { | ||
maxAge?: string | number; | ||
maxAmount?: number; | ||
maxMemory?: number; | ||
webhook?: string; | ||
autoclear?: boolean; | ||
}); | ||
private deleteOutdated; | ||
set(key: any, value: any, maxAge?: string | number): Promise<void>; | ||
setMany(entries: ([any, any, number | string] | [any, any])[]): Promise<void>; | ||
get(key: any, config?: { | ||
validate?: boolean; | ||
delete?: boolean; | ||
}): Promise<any>; | ||
getMany(keys: any[], config?: { | ||
validate?: boolean; | ||
delete?: boolean; | ||
}): Promise<any[]>; | ||
update(key: any, value: any): Promise<void>; | ||
updateMany(entries: [any, any][]): Promise<void>; | ||
delete(key: any): Promise<void>; | ||
deleteMany(keys: any[]): Promise<void>; | ||
has(key: any): Promise<boolean>; | ||
size(): Promise<number>; | ||
keys(): Promise<any[]>; | ||
values(): Promise<any[]>; | ||
clear(): Promise<void>; | ||
memory(): Promise<number>; | ||
recent(): Promise<{ | ||
key: any; | ||
value: any; | ||
expiresAt?: number | undefined; | ||
} | undefined>; | ||
maxAge(maxAge?: string | number): Promise<number>; | ||
maxAmount(maxAmount?: number): Promise<number>; | ||
each(action: Action): Promise<void>; | ||
on(): Promise<void>; | ||
} | ||
declare type SetMethod = (key: Key, value: Value, maxAge?: number | string) => Promise<Record | undefined> | ||
declare type SetManyMethod = (records: ([Key, Value, number | string] | [Key, Value])[]) => Promise<(Record | undefined)[]> | ||
declare type GetMethod = (key: Key, config?: { | ||
validate?: boolean, | ||
delete?: boolean | ||
}) => Promise<Record | undefined> | ||
declare type GetManyMethod = (keys: Key[], config?: { | ||
reverse?: boolean, // default: false | ||
validate?: boolean, // default: true | ||
delete?: boolean // default: false | ||
}) => Promise<(Record | undefined)[]> | ||
declare type UpdateMethod = (key: Key, value: Value, config?: { | ||
updateAge: boolean | ||
}) => Promise<void> | ||
declare type UpdateManyMethod = (records: [Key, Value][], config?: { | ||
updateAge: boolean | ||
}) => Promise<void> | ||
declare type DeleteMethod = (key: Key) => Promise<void> | ||
declare type DeleteManyMethod = (keys: Key[]) => Promise<void> | ||
declare type HasMethod = (key: Key) => Promise<boolean> | ||
declare type SizeMethod = () => Promise<number> | ||
declare type KeysMethod = () => Promise<Key[]> | ||
declare type ValuesMethod = () => Promise<Value[]> | ||
declare type ClearMethod = () => Promise<void> | ||
declare type MemoryMethod = () => Promise<number> | ||
declare type RecentMethod = () => Promise<Record | undefined> | ||
declare type MaxAgeMethod = (newAge?: string | number) => Promise<number> | ||
declare type MaxAmountMethod = (newAmount?: number) => Promise<number> | ||
declare type NewestMethod = () => Promise<Record | undefined> | ||
declare type OldestMethod = () => Promise<Record | undefined> | ||
declare type Event = | ||
| 'set' | ||
| 'setMany' | ||
| 'get' | ||
| 'getMany' | ||
| 'update' | ||
| 'updateMany' | ||
| 'delete' | ||
| 'deleteMany' | ||
| 'has' | ||
| 'size' | ||
| 'keys' | ||
| 'values' | ||
| 'clear' | ||
| 'memory' | ||
| 'recent' | ||
| 'maxAge' | ||
| 'maxAmount' | ||
| 'newest' | ||
| 'oldest' | ||
| 'on' | ||
| 'dump' | ||
declare type OnMethod = (event: Event, action: Function) => Promise<void> | ||
declare type DumpMethod = () => Promise<Record[]> | ||
declare type ImportMethod = (path: string, key: string) => Promise<boolean> | ||
declare type ExportMethod = (path: string, key: string) => Promise<{ path: string | undefined, success: boolean, exportedAt: Date | undefined, version: number }> | ||
declare type MemoryCache = (config?: { | ||
maxAge?: string | number, | ||
maxAmount?: number | ||
}) => { | ||
set: SetMethod, | ||
setMany: SetManyMethod, | ||
get: GetMethod, | ||
getMany: GetManyMethod, | ||
update: UpdateMethod, | ||
updateMany: UpdateManyMethod, | ||
delete: DeleteMethod, | ||
deleteMany: DeleteManyMethod, | ||
has: HasMethod, | ||
size: SizeMethod, | ||
keys: KeysMethod, | ||
values: ValuesMethod, | ||
clear: ClearMethod, | ||
memory: MemoryMethod, | ||
recent: RecentMethod, | ||
maxAge: MaxAgeMethod, | ||
maxAmount: MaxAmountMethod, | ||
newest: NewestMethod, | ||
oldest: OldestMethod, | ||
on: OnMethod, | ||
dump: DumpMethod, | ||
import: ImportMethod, | ||
export: ExportMethod | ||
} | ||
declare const memoryCache: MemoryCache | ||
export { | ||
Key, | ||
Value, | ||
Record, | ||
SetMethod, | ||
SetManyMethod, | ||
GetMethod, | ||
GetManyMethod, | ||
UpdateMethod, | ||
UpdateManyMethod, | ||
DeleteMethod, | ||
DeleteManyMethod, | ||
HasMethod, | ||
SizeMethod, | ||
KeysMethod, | ||
ValuesMethod, | ||
ClearMethod, | ||
MemoryMethod, | ||
RecentMethod, | ||
MaxAgeMethod, | ||
MaxAmountMethod, | ||
NewestMethod, | ||
OldestMethod, | ||
OnMethod, | ||
DumpMethod, | ||
ImportMethod, | ||
ExportMethod, | ||
MemoryCache, | ||
memoryCache as default | ||
} | ||
export default MemoryCache; |
@@ -1,2 +0,1 @@ | ||
export { default as MemoryCache } from './caches/MemoryCache' | ||
export { default as RedisCache } from './caches/RedisCache' | ||
export { default as MemoryCache } from './caches/MemoryCache'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
8
1
0
Yes
26729
14
194
73
1