1.1.0 • Published 3 years ago

@alibrate/cache-manager v1.1.0

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

cache-manager

Manage the cache store in redis

Configure

Add to your configuration file a redis property with server url:

{
 "redis" : {
   "port": 6379,
   "host": "redis-host",
   "options": {}
 }
}

Usage

let cacheManager = require ('@alibrate/cache-manager');

let payload = { data: 'to cache'};
let expireSeconds = 60;

// generate store key with md5 using a namespace and payload
let keyMd5 = cacheManager.createMd5Key (payload, 'data1', 'data2');

// save cache
cacheManager.save(keyMd5, payload, expiresOn).then(function(resp) {
  console.log(resp)
}).catch(function(err){
  console.log(err)
});

// get cache content
cacheManager.get(keyMd5).then(function(content){
  console.log(content);
})

// build a key with namespace
let key = createKey('user1', 'book1');
// delete cache by name
cacheManager.removeAllCache(key));

// remove only one key
cacheManager.remove(keyMd5);
1.1.0

3 years ago

1.0.1

6 years ago

1.0.0

6 years ago