#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.
npm install metle
import { metle } from "https://deno.land/x/metle/mod.ts";
Load the default Metle instance
// NodeJS
import metle from 'metle'
// Deno
import { metle } from 'https://deno.land/x/metle/mod.ts'
metle.setItem('foo', 'bar')
const foo = metle.getItem('foo')
Create a new Metle instance
// NodeJS
import { Metle } from 'metle'
// Deno
import { Metle } from 'https://deno.land/x/metle/mod.ts'
const metleInstance = new Metle({TTL: 2, maxRequest: 50})
metle.setItem('foo', 'bar')
const foo = metle.getItem('foo')
- 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 = new 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
}