Small JS lib for caching:
- Use array as key for storing cache instead of string ( {blogId:1,type:'view'} )
- Clear cache using context (clear blog posts of an author)
- Support localStorage, array, cookies (WIP, only localStorage and array are available at the moment)
See the project homepage.
Using Bower:
bower install cache-js
Or grab the file source (minified).
Save cache:
cacheJS.set({blogId:1,type:'view},'<h1>Blog 1</h1>');
cacheJS.set({blogId:2,type:'view},'<h1>Blog 2</h1>', null, {author:'hoangnd'});
cacheJS.set({blogId:3,type:'view},'<h1>Blog 3</h1>', 3600, {author:'hoangnd',categoryId:2});
Retrieve cache:
cacheJS.get({blogId: 1,type: 'view'});
Flush cache
cacheJS.removeByKey({blogId: 1,type: 'view'});
cacheJS.removeByKey({blogId: 2,type: 'view'});
cacheJS.removeByContext({author:'hoangnd'});
Switch provider
cacheJS.use('array');
cacheJS.use('array').set({blogId:1},'<h1>Blog 1</h1>')};
For advanced usage, see the documentation.
Start with docs/INDEX.md
.
MIT. See LICENSE.txt
in this directory.