middy-redis
v1.0.2
Published
Middy middleware that loads redis for you and closes your connection when you're done
Downloads
1
Readme
middy-redis
Middy middleware for connecting to redis. Complete documentation
Getting Started
Installing middy-redis
npm install --save middy redis # You need middy and redis installed
npm install --save middy-redis
Running the tests
npm test
Usage
const middyRedis = require('middy-redis')
const middy = require('middy')
const someHandler = (event, context, callback) => {
// The redis instance is accessible from the event object
event.redis.get('some_key', (err, value) => {
if (err) {
return callback(err)
}
callback(null, value)
}
}
// Lets you connect to a different redis instance based on information in the event.
// This example hard codes a value.
let resolver = (event) => {
return 'redis://localhost:6379'
}
const handler = middy(someHandler)
.use(middyRedis({ redisURIResolver: resolver })
module.exports = { handler }
Contributing
Feel free to open a Pull Request or Issue w/ a bug report or feature request.