0.0.2 • Published 4 years ago

omni-cache v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

omni-cache

NPM Version NPM Downloads Maintenance GitHub issues

Simple memory cache from server side.

How to

Install

npm i --save omni-cache
or
yarn add omni-cache

Use

Without options on create

const { Cache } = require('omni-cache');

const cache = new Cache();

cache.put('myKey', 'myValue', 1500);              // Time im ms
cache.get('myKey');                               // myValue
cache.keys();                                     // [ 'myKey' ]
cache.size();                                     // 1
cache.debug(true);                                // No return
cache.inDebug();                                  // true
cache.exportJson();                               // true
cache.del('myKey');                               // true
cache.clear();                                    // No return

With options on create

const { Cache } = require('omni-cache');

const cache = new Cache({
  debug: true,
  ttl: 1500
});

cache.put('myKey', 'myValue');                    // Expire time id ttl by default
cache.get('myKey');                               // myValue
cache.keys();                                     // [ 'myKey' ]
cache.size();                                     // 1
cache.inDebug();                                  // true
cache.debug(false);                               // No return
cache.inDebug();                                  // false
cache.exportJson();                               // true
cache.del('myKey');                               // true
cache.clear();                                    // No return

npm