Skip to content

DannyBen/node-jsoncache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonCache

A Node.js module for caching JSON objects or raw data.

Install

npm install jsoncache

Use

var Cache = require('jsoncache');

var cache = new Cache({ dir: './cache', life: 1, mode: 'json' });
var data = { firstName: "Bruce", lastName: "Dickinson" };

// Using the sync methods 
cache.setSync('key', data);
var restored = cache.getSync('key');
console.log(restored);

// Using the async methods
cache.set('keyasync', data, function(err) {
	if(err) console.log(err.message);
});

cache.get('keyasync', function(err, data) {
	if(err) console.log(err.message);
	if(data === undefined) console.log('cache expired');
	console.log(data);
});

About

A Node.js module for caching JSON objects and raw data

Resources

License

Stars

Watchers

Forks

Packages

No packages published