omni-cache

0.0.2 • Public • Published

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

Package Sidebar

Install

npm i omni-cache

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

19.8 kB

Total Files

9

Last publish

Collaborators

  • andreoneti