Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mem-cache

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mem-cache

simple in memory key/value cache with autoclean by timeout

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
784
decreased by-10.4%
Maintainers
1
Weekly downloads
 
Created
Source

node-mem-cache

A simple in-memory cache for node.js

  • Entries will be disposed on timeout
  • Emits an event on each dispose item by timeout

Installation

npm install mem-cache

Usage

var Cache = require('mem-cache');
var cache = new Cache();

cache.set('foo', 'bar');
console.log(cache.get('foo'))

API

constructor = function(options)
  • '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.

Methods

set = function(key, value, timeout)
  • Stores or updates a value.
    • key {string} Required.
    • value {any} Required.
    • timeout {number} Optional. Specifies in milliseconds the timeout for this entry.
get = function(key)
  • 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.
remove = function(key)
  • Deletes the value and its key from the cache
clean = function()
  • Deletes cache's entries all keys

Properties

keys

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

length
  • Property that returns the current number of entries in the cache

Events

expired
  • This event will be emitted for every cache entry that was removed because timed out

Keywords

FAQs

Package last updated on 06 Oct 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc