A simple Redis wrapper around the ioredis module.
This simple project is intended to mock real key value stores likes Redis or file system based stores. It can also be used in local scripts to run code that assume a key value store exists.
It requires a delay
services to be passed in, you can find an implementation
in the common-services
project.
Instantiate the Redis service
Kind: global function
Returns: Promise.<RedisService>
- A promise of the Redis service
Param | Type | Description |
---|---|---|
services | Object |
The services to inject |
[services.ENV] | Object |
An environment object |
services.REDIS | function |
The configuration object as given to node-redis |
[services.REDIS_PASSWORD_ENV_NAME] | function |
The environment variable name in which to pick-up the Redis password |
services.log | function |
A logging function |
Example
import initRedisService from 'simple-redis-service';
const redis = await initRedisService({
REDIS: {
host: 'localhost',
port: 6379,
},
ENV: process.env,
log: console.log.bind(console),
});
const value = await redis.get('my_key');