https://github.com/katilius/functional-cache-redis
functional-cache provider using Redis as data source
https://github.com/katilius/functional-cache-redis
Last synced: 3 months ago
JSON representation
functional-cache provider using Redis as data source
- Host: GitHub
- URL: https://github.com/katilius/functional-cache-redis
- Owner: katilius
- License: mit
- Created: 2018-12-09T16:21:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T07:41:14.000Z (over 2 years ago)
- Last Synced: 2025-03-12T11:06:57.190Z (4 months ago)
- Language: JavaScript
- Size: 938 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Functional Cache Redis
Cache provider for [functional-cache](https://www.npmjs.com/package/functional-cache) library.
## Usage
```javascript
const cacheFactory = require('functional-cache');
const RedisProvider = require('functional-cache-redis');const cache = cacheFactory.createNew(new RedisProvider());
const getBooks = cache.cacheCalls(getBooksFromApi);
```## Customization
Redis cache provider uses [Redis](https://www.npmjs.com/package/redis) npm library. When creating new `CacheProvider` instance without params, it initiates new client connecting to `localhost:6379`. This can by configured simply by providing different client instance to `RedisProvider` constructor:
```javascript
const redisClientWithDifferentOptions = getRedisClient();
const cache = cacheFactory.createNew(new RedisProvider(redisClientWithDifferentOptions));
const getBooks = cache.cacheCalls(getBooksFromApi);```