Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple and naive in-memory cache
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
.gitignore
.npmignore
README.md
index.js
package.json

README.md

im-cache

im-cache is a simple and naive in-memory object cache.

Install

npm install im-cache

Usage

cache.set(key, object[, timeout])

var cache = require('im-cache');
//Cache {data: true} for one hour with key "key"
cache.set("key", {data: true}, 1000*60*60)
//Cache {data: true} forever with key "key"
cache.set("key", {data: true})

cache.get(key)

// Set data:
cache.set("key", {data: true}, 10000)
// Equals {data: true}:
cache.get("key");

cache.remove(key)

// Set data:
cache.set("key", {data: true}, 10000)
// Equals {data: true}:
cache.remove("key");
// Equals undefined:
cache.get("key");

cache.size()

Returns cache size

cache.flush()

Empties cache

Something went wrong with that request. Please try again.