express-redis
v2.0.1
Published
Express middleware for a redis connection.
Downloads
190
Readme
Redis Express Middleware
This is a simple express middleware for redis
and provides a shared redis db
object across all requests.
Basic Usage
app.use(require('express-redis')());
app.get('/', function (req, res, next) {
req.db.get('some_key', function (err, reply) {
if (err) {
return res.status(500).end();
}
res.json(reply);
});
});
Advanced Usage
Any options available to the redis.createClient
method may be used when instantiating the redis middleware:
var options = {
return_buffers: true,
auth_pass: 'superSecretPassword'
};
app.use(require('express-redis')(6379, '127.0.0.1', options, 'name'));
The name string allows you to specify a custom varaible name to provide the middleware on
for example providing the name 'redis'
would allow you to access redis via res.redis