coka-cachejs
v1.1.6
Published
Cachejs is a library that will allow you to set up a private and powerful cache system in your javascript application.
Downloads
21
Maintainers
Readme
CacheJs
javascript, cache system, SessionStorage, LocalStorage
Cachejs is a library that will allow you to set up a private and powerful cache system in your javascript application.
Installing / Getting started
Source can be loaded via bower or downloaded from this repo. If you don't use a module loader it will be added to window.Cache
# bower
$ bower install coka-cachejs
# yarn
$ yarn add coka-cachejs
If you want to try the sample codes below, just open your browser's console and enter them.
Browser
<script type="text/javascript" src="cache.js"></script>
<script>
var cache = new Cache.Memory(25, 300, 'default');
cache.onWrite(function(key, data){
console.log('An entry has been added to the cache with the key "' + key + '" : ');
console.log(data);
});
cache.onRead(function(key, data){
console.log('An entry was read in the cache with the key "' + key + '" : ');
console.log(data);
});
cache.write('cachejs', {foo: 'foo'});
if (cache.has('cachejs')) {
var data = cache.read('cachejs');
console.log(data);
}
</script>
Require.js
require.config({
paths: {
cache: 'cache.js',
}
});
define(['cache'], function (Cache) {
var cache = new Cache.Memory(25, 300, 'default');
cache.onWrite(function(key, data){
console.log('An entry has been added to the cache with the key "' + key + '" : ');
console.log(data);
});
cache.onRead(function(key, data){
console.log('An entry was read in the cache with the key "' + key + '" : ');
console.log(data);
});
cache.write('cachejs', {foo: 'foo'});
if (cache.has('cachejs')) {
var data = cache.read('cachejs');
console.log(data);
}
});
Latest updates
For notes about latest changes please read CHANGELOG.
Versioning
For the versions available, see the tags on this repository.
Licensing
This library is under the MIT license. See the complete license in the library.