1.0.0 • Published 10 years ago

kcache v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

Kcache

Small caching api for node. Can also be used in the browser.

Installation

Download via GitHub or NPM

npm install kcache

Initialize like this:

var cache = Kcache();

You can then set, get, observe and print out the data as json using these methods:

set

cache.set("yourKey", "yourValue", function (oldValue, newValue) { //yourCallback });

the callback (last parameter) is optional, so you don't have to provide one if you don't need to.

get

cache.get("yourKey");

This returns an object that looks like that:

{
	data: "yourValue",
	timestamp: 123456789
}

observe

cache.setNotifier("yourKey", function(oldValue, newValue) { //yourCallback });

You can also set a callback while setting a property value, by providing the callback as a third parameter in the set method.

print JSON

You can either get the json for only one item or the whole thing.

cache.getJSON("yourKey");
acache.getJSON();