https://github.com/holyshared/cachemanager
Cash API which uses localStorage and sessionStorage is offered.
https://github.com/holyshared/cachemanager
Last synced: about 1 year ago
JSON representation
Cash API which uses localStorage and sessionStorage is offered.
- Host: GitHub
- URL: https://github.com/holyshared/cachemanager
- Owner: holyshared
- Created: 2011-12-03T06:09:17.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-12-04T03:20:21.000Z (over 14 years ago)
- Last Synced: 2025-06-15T06:45:03.386Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CacheManager
============================================
This library offers the cash function which uses localStorage newly added by HTML5, and sessionStorage.
Cache can be used in very easy code.
How to use
--------------------------------------------
CacheManager is a cache class which can specify the storage to be used.
The storage which can be used is as follows.
### Storage type
* local - **localStorage** is used.
* session - **sessionStorage** is used.
* hash - storage which uses hash is used.
### CacheManager
Acquisition of cache and cache can be used in a simple form as follows.
A **set** method is used for cacheing.
The argument is a milli second about the key of cache, the contents to cache, and the maintenance period of cache, and it makes it into turn.
var user = {
name: 'foo',
age: 28
};
var cache = new CacheManager('hash');
cache.set(user.name, user, 1 * 60 * 60 * 1000);
Conversely, a **get** method is used for acquiring the cached contents.
The get method which uses the following method for acquiring the information on cache returns a **CacheManager.CacheContent** object.
var cache = cache.get(user.name);
#### CacheManager.CacheContent
* getKey - The key of cache is acquired.
* getStorage - The used storage is acquired.
* getLimit - The term of validity of cache is acquired by a time stamp.
* getContent - The cached contents are acquired.
* isLimit - true is returned when the term of validity of cash has passed.
* destroy - Cache is destory.
Screenshot
--------------------------------------------