@mimik/cache-helper
v3.1.1
Published
Cache helper for mimik microservices
Readme
cache-helper
Example
import cacheHelper from '@mimik/cache-helper';- cache-helper
- ~cacheHelper(config) ⇒ object
- async
- ~rpCached(type, options) ⇒ Promise
cache-helper~cacheHelper(config) ⇒ object
Create a cache helper instance.
Kind: inner method of cache-helper
Returns: object - An object containing rpCached.
| Param | Type | Description |
| --- | --- | --- |
| config | object | Configuration object. |
| config.cache | object | Cache settings. |
| config.cache.set | string | Set to 'on' to enable caching; any other value disables it. |
| config.redisSettings | object | Redis settings. |
| config.redisSettings.request | object | Request-level Redis settings. |
| config.redisSettings.request.TTL | number | TTL in seconds for cached GET responses. |
cache-helper~rpCached(type, options) ⇒ Promise
Make a cached request.
Kind: inner method of cache-helper
Category: async
Throws:
- Error Will throw the same error as
rpAuthof@mimik/oauth-helper.
Requires: module:@mimik/oauth-helper, module:@mimik/rediser, module:@mimik/sumologic-winston-logger
Fulfil: object - Response of the rpAuth of @mimik/oauth-helper request.
| Param | Type | Description |
| --- | --- | --- |
| type | string | Type of micro-service to request. |
| options | object | Options for the request. Similar to rpAuth of @mimik/oauth-helper options. |
| options.method | string | HTTP method (e.g. 'GET', 'DELETE'). |
| [options.uri] | string | Request URI. Used as the cache key for GET requests. |
| [options.url] | string | Request URL. Used as the cache key if options.uri is not set. |
| [options.headers] | object | Request headers, including optional x-correlation-id for request tracing. |
