FlexiCache automatically balance caches by expiration time, frequency of data accesses, access timeout, maximum stack size and/or memory limit.
Supported Platforms:
- Browser
- Node.js
Supported Module Definitions:
- AMD (RequireJS, Xone)
- CommonJS (Node.js)
- Closure (Xone)
- Global (window)
All Features:
- Auto-cleanup cache by:
- Expiration time
- Frequency of data accesses
- Access timeout
- Maximum size (stack)
- Memory limit
- Allows free combination of all the above options
- Debug infos & statistics
- Save / Load dump
Optional Plugins: (actually unreleased)
- Redis API Adapter
- Filesystem Plugin (HTML5)
- Filesystem Plugin (Node.js)
- LocalStorage Plugin (HTML5)
<html>
<head>
<script src="https://cdn.rawgit.com/nextapps-de/flexicache/master/flexicache.min.js"></script>
</head>
...
npm install flexicache
In your code include as follows:
var FlexiCache = require("flexicache");
Or pass in options when requiring:
var cache = require("flexicache").create({/* options */});
AMD
var FlexiCache = require("./flexicache.js");
var cache = new FlexiCache();
alternatively you can also use:
var cache = FlexiCache.create();
FlexiCache.create(options)
var cache = new FlexiCache({
// default values:
expire: 60 * 60 * 1000, // 1 hour
size: 1000,
auto: true,
timeout: false,
memory: false
});
Cache.add_(id, *)
cache.add(10000, 'foo');
add more complex objects:
cache.add(10025, {
id: 10025,
name: 'foo'
});
clone and add objects:
cache.add(10025, {
id: 10025,
name: 'foo'
}, true);
Cache.update(id, *)
cache.update(10000, 'bar');
clone and update objects:
cache.update(10025, {
id: 10025,
name: 'foo'
}, true);
Cache.remove(id)
cache.remove(10025);
cache.destroy();
Cache.init(options)
cache.init();
cache.info();
Returns information about the cache, e.g.:
{
"bytes": 3600356288,
"id": 0,
"auto": false,
"expire": 3600,
"size": 10000,
"status": false
}
cache.cleanup();
Author FlexiCache: Thomas Wilkerling
License: Apache 2.0 License