Skip to content

nextapps-de/flexicache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlexiCache

Lightweight auto-balancing cache handler with zero dependencies.

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)

Installation

HTML / Javascript
<html>
<head>
    <script src="https://cdn.rawgit.com/nextapps-de/flexicache/master/flexicache.min.js"></script>
</head>
...
Node.js
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");

Usage (API)

Create a new cache

var cache = new FlexiCache();

alternatively you can also use:

var cache = FlexiCache.create();
Create a new cache with custom options

FlexiCache.create(options)

var cache = new FlexiCache({

    // default values:

    expire: 60 * 60 * 1000, // 1 hour
    size: 1000,
    auto: true,
    timeout: false,
    memory: false
});

Add items to a cache

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);

Update item of the cache

Cache.update(id, *)

cache.update(10000, 'bar');

clone and update objects:

cache.update(10025, {
    
    id: 10025,
    name: 'foo'
    
}, true);

Remove item to the cache

Cache.remove(id)

cache.remove(10025);

Destroy the cache

cache.destroy();

Initialize the cache

Cache.init(options)

cache.init();

Get info

cache.info();

Returns information about the cache, e.g.:

{
    "bytes": 3600356288,
    "id": 0,
    "auto": false,
    "expire": 3600,
    "size": 10000,
    "status": false
}

Optimize / Cleanup cache

cache.cleanup();

Author FlexiCache: Thomas Wilkerling
License: Apache 2.0 License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published