jquery-local-cache
v0.0.5
Published
jquery-local-cache allows you to cache data on the heap, it clears on page refresh, can be used for single page apps that need to cache more than webstorage allows
Downloads
11
Maintainers
Readme
jquery-local-cache
Why use this?
There are other caching solutions available that do similar things, however, they all use WebStorage only, this solution uses the heap, so you're not limited to only 5MB of storage. When you need large amounts of data to be readily available to the user on a Single Page Application, this is your best bet.
How do I use it?
There are 5 functions currently available to you in this package.
get
Get an entry from the cache.
var cachedData = $(document).localCache('get', item);
set
This creates an entry in the cache.
function functionOnCompletion(data) {
console.log(data);
}
var options = {
data: ['data', 'to', 'store'],
callback: functionOnCompletion
};
$(document).localCache('set', item, options);
remove
Remove an entry from the cache.
$(document).localCache('remove', item)
exists
Returns a boolean value -- if the item exists returns true
, else returns false
var itemDoesExist = $(document).localCache('exists', item);
getAll
Returns a JSON object of all items in cache
var allItemsInCache = $(document).localCache('getAll');