open-index/open-npm huggingface dataset:
npm package: @alibrate/cache-manager
Description: Manage cache store
Author: alibrate
Latest version: 1.1.0

# 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

```javascript

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

```