Getting Started

Install

npm install node-internal-cache --save

Initialize

const NodeCache = require("node-internal-cache");
const myCache = new NodeCache();

Options

OptionTypeDefaultDescription
stdTTLnumber0Standard ttl in seconds for every generated cache element. 0 = unlimited
checkperiodnumber600Period in seconds for the automatic delete check interval. 0 = no periodic check
useClonesbooleantrueEn/disable cloning of variables. true returns a copy. false saves and returns just the reference
deleteOnExpirebooleantrueWhether variables will be deleted automatically when they expire
enableLegacyCallbacksbooleanfalseRe-enables usage of callbacks instead of sync functions
maxKeysnumber-1Maximum amount of keys. -1 disables the limit
const NodeCache = require("node-internal-cache");
const myCache = new NodeCache({ stdTTL: 100, checkperiod: 120 });

Since 4.1.0: keys can be given as string or number, but are cast to string internally. All other types throw an error.