npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

expredis

v0.2.2

Published

Express session store for redundant Redis instances

Readme

expredis

Current Version Build Status via Travis CI Dependencies

belly-button-style

Express session store for use with redundant Redis instances. All operations are performed simultaneously on an arbitrary number of independent Redis instances. When retrieving data, the result is taken from the first Redis instance to respond.

Expredis implements the Express Session Store API, with the exception of the store.all(callback) method.

Basic Usage

Expredis exports a single function, which accepts the express-session module as it's only argument. The result is a Redis store that can be passed to Express session middleware.

'use strict';
const Expredis = require('expredis');
const Express = require('express');
const ExpressSession = require('express-session');
const RedisStore = Expredis(ExpressSession);
const app = new Express();

app.use(ExpressSession({
  name: 'session',
  secret: 'foobar',
  resave: true,
  saveUninitialized: false,
  cookie: { secure: true, maxAge: 5000 },
  store: new RedisStore({
    clients: [
      { port: 6379 },
      { port: 6380 }
    ]
  })
}));

app.get('/setter', (req, res, next) => {
  req.session.firstName = 'Peter';
  req.session.lastName = 'Pluck';
  res.send({ operation: 'set' });
});

app.get('/getter', (req, res, next) => {
  const { firstName, lastName } = req.session;
  res.send({ firstName, lastName });
});

API

This section describes the options that can be passed to the RedisStore constructor.

  • serializer (Object) - An object that is API compatible with the built-in JSON object. This is used to parse and stringify data as it is read from and written to Redis. Defaults to JSON.
  • prefix (String) - A string that is prepended to keys stored in Redis. This prevents collisions with data unrelated to the session storage. Defaults to 'session'.
  • unref (Boolean) - When true, Redis clients are unref'ed. Defaults to false.
  • ttl (false or Integer) - Defines the TTL for data written to Redis. If ttl is false, then no TTL is used, and data must be evicted in some other manner. If ttl is an integer, then it is used as the TTL value in seconds. If a value is not provided, then Expredis will try to use the session cookie's maxAge value. If a maxAge is not available, a default value of one day is used.
  • clients (Array of Objects) - Each array element is a configuration object used to instantiate a Redis client. See the redis module's documentation for more details. Note that the enable_offline_queue option is unconditionally set to false.

Events

RedisStore extends Node's EventEmitter. As such, it emits several events, which are documented here.

  • error - Emitted when an error occurs on one of the Redis clients. The handler takes an Error object as the only argument. The client that generated the error is attached to the Error object via the client property.
  • connect - Emitted each time one of the Redis clients successfully connects. The client that connected is passed to the handler as the only argument.
  • ready - Emitted each time one of the Redis clients emits its own ready event. The client that became ready is passed to the handler as the only argument.