@terrajs/mono-redis
v1.0.1
Published
Redis module for Mono
Downloads
2
Readme
Redis module for Mono
Installation
npm install --save @terrajs/mono-redis
Then, in your configuration file of your Mono application (example: conf/application.js
):
module.exports = {
mono: {
modules: ['@terrajs/mono-redis']
}
}
Configuration
Mono-Redis will use the redis
property of your configuration (example: conf/development.js
):
module.exports = {
mono: {
redis: {
port: 8047,
// See https://github.com/NodeRedis/node_redis#options-object-properties for more argument
}
}
}
Usage
In your modules files, you can access redis
instance like this:
const { redis } = require('@terrajs/mono-redis')
redis.set('key', 'value', () => { console.log('value setted') })
redis.get('key', (value) => { console.log(`value is ${value}`)})
The current functions of redis client are using callback function but you can convert it to async function with the mono utils
const { redis } = require('@terrajs/mono-redis')
const { cb } = require('@terrajs/mono/utils')
await cb(redis.set.bind(redis), 'key', 'value')
const result = await cb(redis.get.bind(redis))