simple in memory key/value cache with autoclean by timeout


A simple in-memory cache for node.js

  • Entries will be disposed on timeout
  • Emits an event on each dispose item by timeout
npm install mem-cache
var Cache = require('mem-cache');
var cache = new Cache();

cache.set('foo', 'bar');
  • 'options' argument is an optional object instance containing the configuration.
    • timeout. Optional number. Specifies in milliseconds the default timeout for each entry. Default 60000 ms.
    • doesNotRenewTimeout Optional boolean. Specifies if entries's timeout should be reseted after each query or update. Default false.
    • timeoutDisabled Optional boolean. Enable/diable timeout feature. If timeout feature is desable, items will not expire. Default false.
  • Stores or updates a value.
    • key {string} Required.
    • value {any} Required.
    • timeout {number} Optional. Specifies in milliseconds the timeout for this entry.
  • Retreives a value for a given key, if there is no value for the given key a null value will be returned
    • key {string} Required.
  • Deletes the value and its key from the cache
  • Deletes cache's entries all keys

*Returns an string array containing all items' keys. It will include keys of items that are expired but weren't been removed yet.

  • Property that returns the current number of entries in the cache
  • This event will be emitted for every cache entry that was removed because timed out