Skip to content

CedrickOka/cachejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CacheJs Logo

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.

GitHub version GitHub issues GitHub forks GitHub stars GitHub license

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.min.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.min',
	}
});

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published