3.0.2 • Published 2 years ago

lazy-cacache v3.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
2 years ago

README

a wrap class of cacache

install

npm install lazy-cacache

demo

API

import Cacache from 'lazy-cacache';
import * as path from 'path';

(async () => {

	// create Cacache object
	let cache1 = new Cacache('lazy-cacache');
	// => cachePath: 'xxxx\\node_modules\\.cache\\lazy_cacache'
	let cache2 = await Cacache.createAsync({
		name: 'lazy-cacache',
		useGlobalCache: true,
	});
	// => cachePath: 'T:\\cache\\npm-cache\\.cache\\lazy_cacache'
	let cache3 = await Cacache.createAsync({
		cachePath: path.join(__dirname, '.mycache'),
		// if not set, u will need create by self
		autoCreateDir: true,
	});
	// => cachePath: 'xxxx\\test\\.mycache'

	console.dir(cache1);
	console.dir(cache2);
	console.dir(cache3);

	let key1 = 'data1';
	let key2 = 'data2';

	// delete all exists cache
	await cache1.removeAll();

	// read cache info
	console.log(await cache1.readDataInfo(key1));
	console.log(await cache1.readDataInfo(key2));

	// save a cache data
	console.log(await cache1.writeData(key1, 'data111'));
	console.log(await cache1.writeJSON(key2, {
		data: 222,
	}));

	// read cache info again, see what return
	console.log(await cache1.readDataInfo(key1));
	console.log(await cache1.readDataInfo(key2));

	// read cache data
	console.log(await cache1.readData(key1));
	console.log(await cache1.readJSON(key2));

})();
3.0.2

2 years ago

2.0.4

4 years ago

2.0.0

4 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago