🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

node-memo

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

node-memo

An in-memory cache module.

0.0.4
unpublished
latest
Source
npm
Version published
Maintainers
1
Created
Source

node-memo

An in-memory cache module.

Getting Started

const NodeMemo = require('node-memo');

(async function () {
    const cache = new NodeMemo(NodeMemo.Second * 5);

    cache.set('key', 'value');
    console.log(cache.get('key')); // 'value'

    await NodeMemo.wait(NodeMemo.Second * 5);

    console.log(cache.get('key')); // null
})();

API

new NodeMemo(maxAge)

Create a cache.

ParamTypeDescription
maxAgenumberThe max age of the cache.

this.maxAge ⇒ number

Get the max age of the cache.

Kind: instance property of NodeMemo

this.maxAge

Set the max age of the cache.

Kind: instance property of NodeMemo

ParamTypeDescription
newAgenumberThe new max age of the cache.

this.get(key) ⇒ *

Get the value for the specified key in the cache.

Kind: instance method of NodeMemo

ParamTypeDescription
key*The key tied to the data in the cache.

this.set(key, value)

Set a key and value in the cache.

Kind: instance method of NodeMemo

ParamTypeDescription
key*The key tied to the value in the cache.
value*The value tied to the key in the cache.

this.delete(key)

Delete an entry in the cache.

Kind: instance method of NodeMemo

ParamTypeDescription
key*The key tied to the value in the cache.

this.has(key) ⇒ boolean

Check if a key-value pair exists in the cache.

Kind: instance method of NodeMemo

ParamTypeDescription
key*The specified key in the cache.

this.keys() ⇒ *[]

Get the keys in the cache.

Kind: instance method of NodeMemo

this.values() ⇒ *[]

Get the values in the cache.

Kind: instance method of NodeMemo

this.entries() ⇒ *[]

Get the entries in the cache.

Kind: instance method of NodeMemo

this.time(key) ⇒ number

Get the current time of a cached item.

Kind: instance method of NodeMemo

ParamTypeDescription
key*The specified key in the cache.

this.clear()

Clear the cache.

Kind: instance method of NodeMemo

NodeMemo.Second ⇒ number

Get 1 second in milliseconds.

Kind: static property of NodeMemo

NodeMemo.Minute ⇒ number

Get 1 minute in milliseconds.

Kind: static property of NodeMemo

NodeMemo.Hour ⇒ number

Get 1 hour in milliseconds.

Kind: static property of NodeMemo

NodeMemo.Day ⇒ number

Get 1 day in milliseconds.

Kind: static property of NodeMemo

NodeMemo.wait(ms) ⇒ Promise

Wait a set amount of time.

Kind: static property of NodeMemo

ParamTypeDescription
msnumberThe amount of time to wait in milliseconds.

Author

Kazi Jawad

FAQs

Package last updated on 03 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts