Nonchalantly Perusing Magazines

    express-redis

    2.0.1 • Public • Published

    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

    Keywords

    none

    Install

    npm i express-redis

    DownloadsWeekly Downloads

    87

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    9.24 kB

    Total Files

    12

    Last publish

    Collaborators

    • elliotttf