er

express-redis

Express middleware for shared redis connection.

Showing:

Popularity

Downloads/wk

107

GitHub Stars

7

Maintenance

Last Commit

3yrs ago

Contributors

4

Package

Dependencies

1

Size (min+gzip)

2.6KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Express Redis

Readme

Redis Express Middleware

Greenkeeper badge

Build Status Coverage Status

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial