node-api-cache

1.0.0 • Public • Published

node-api-cache

A simple tool for generate cache for node.js

Get started

Usage

const NodeApiCache = require('node-api-cache');
const cacheClient = new NodeApiCache({
  useNodeCache: true, 
  useRedis: true, 
  redisConfig: { uri: 'redis://localhost:6379' }
})

// set cache will effect both in local cache and redis
cacheClient.set('key', 'value');

// return promise as default
cacheclient.get('key').then(result => {
  console.log(result)
})

API

constructor

new NodeApiCache({
  useNodeCache,
  nodeCacheTime,
  useRedis,
  redisConfig,
  redisCacheTime
})
  • @params
  • useNodeCache: whether use local node cache;
  • nodeCacheTime: the local cache expired time (in millisecond), default is 10 minutes;
  • useRedis: whether to use redis to store your cache;
  • redisConfig: the redis configuration;
  • redisCacheTime: the redis cache expires time (in second), default is 3 hours

set

set = function(key, value)

get

get = function(key)

clearLocalCache

clearLocalCache = function()

Readme

Keywords

Package Sidebar

Install

npm i node-api-cache

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

12.1 kB

Total Files

6

Last publish

Collaborators

  • ymyqwe