request-cache
Simple request caching using Redis for request.
Tested with redis clients: node_redis ioredis
Installation
npm i --save request-cache
API Reference
Example
const requestCache = ;const rCache = ;const cacheKey; ;
function
⏏
module.exports(redisClient, [options]) ⇒ Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
redisClient | object |
an instance of a redis client | |
[options] | object |
Options for cache management | |
[options.algorithm] | string |
"md5" |
Any available system hashing algorithm to generate cache key (more info) |
[options.encoding] | string |
"hex" |
Encoding algorithm to use for encoding hashed cache key |
[options.ttl] | number |
3600 |
Time in seconds for cache time-to-live |
[options.refresh] | number |
0 |
Time in seconds to refresh time-to-live (this does not initiate a new request) |
[options.queryCacheKeys] | array |
Query param keys to use for generating cache key | |
[options.keyPrefix] | string |
Prefix for generated cache keys |
Examples
With Basic Requests
const requestCache = ;const rCache = ; const cacheKey = ;
With Request Object
const requestCache = ;const rCache = ; const cacheKey = ;
With Cache Key Options
const requestCache = ;const rCache = ; const cacheKey = ;
License
Apache 2.0