Metle
Metle is a memory storage for NodeJS and Deno that supports caching with TTL and maximum number of requests to keep the cache up to date.
NodeJS setup
npm install metle
Deno import
;
Usage
Load the default Metle instance
// NodeJS// Deno metle const foo = metle
Create a new Metle instance
// NodeJS// Deno const metleInstance = TTL: 2 maxRequest: 50metle const foo = metle
API
- getItem(key: string): any
- setItem(key: string, value: any, timers?:ITimers): boolean
- updateItem(key: string, value: any, timers?:ITimers): boolean
- hasItem(key: string): boolean
- resetItemCounter(key: string, timers?: ITimers): boolean
- removeItem(key: string): boolean
Default timers TTL = 10 (minutes value) maxRequest = 0
Metle constructor
const metle = timers?: ITimers
Interface ITimers
interface ITimers TTL?: number // default: 10 (min), maximum time to live of an item, 0 for infinite maxRequest?: number // default: 0, maximum number of gets until the item is removed, 0 for infinite