Realtime data-sync support for Redis in Meteor
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.npm/package WIP on redis observe Jun 18, 2014
.gitignore Straight copy of mongo-livedata -> redis-livedata Jun 11, 2014 Update Oct 29, 2014
allow_tests.js Replace tests on allow/deny rules Jul 1, 2014
doc_fetcher.js Remove all debug output Jul 10, 2014
doc_fetcher_tests.js Rename mongo-livedata to redis-live in tests & stats Jun 11, 2014
keyspace_notification_observe_driver.js Remove all debug output Jul 10, 2014
local_collection_driver.js Propagate the collection name to the local driver Jul 10, 2014
observe_changes_tests.js Rename MongoInternals -> RedisInternals Jun 11, 2014
observe_multiplex.js Drop the dependency on LocalCollection in a couple of places. Jun 18, 2014
oplog_tailing.js Avoid publishing unhandled sequence keys as keyspace operations. Feb 5, 2015
oplog_tests.js Rename mongo-livedata to redis-live in tests & stats Jun 11, 2014
package.js Bump version Feb 5, 2015
redis_client.js Remove all debug output Jul 10, 2014
redis_collection.js Be more careful with local redis commands. Jul 4, 2014
redis_collection_tests.js Don't support ObjectID, just string keys Jun 11, 2014
redis_commands.js Initial support for redis hash commands Jul 3, 2014
redis_driver.js Remove references to `LocalCollection` where necessary. Jan 29, 2015
redis_livedata_tests.js Remove the multiple publish test Jul 10, 2014
redis_watcher.js Make RedisObserver a first-class object; support stop() Jun 12, 2014
remote_collection_driver.js Correctly forward the collection name to redis cursors Jul 10, 2014
sync_map.js Create SynchronousMap and meteorOnce Jun 30, 2014

Redis Livedata

redis-livedata is a Meteor unipackage available on Atmosphere.

The goal of this package is to bring full-stack reactivity support for Redis in Meteor applications. This includes data-sync and latency-compensation, combined with Meteor's plug'n'play packaging interface, ease of use and flexible permissions system.


Add this package to your Meteor app:

meteor add slava:redis-livedata

Since Redis is not yet shipped with Meteor or this package, you need to have a running Redis server and a url to connect to it. You can install Redis locally on Mac OS X with homebrew brew install redis or by following the instructions for other platforms. The latest tested and officially supported version of Redis is 2.8.9.

To configure the Redis server connection information, pass its url as the REDIS_URL environment variable to the Meteor server process. It defaults to localhost:6379.

env REDIS_URL=redis://username:password@ meteor

To provide reactivity, this package uses Redis Keyspace Notifications. You need to enable keyspace notifications; you should do this either from redis-cli:

CONFIG SET notify-keyspace-events AKE

or set the REDIS_CONFIGURE_KEYSPACE_NOTIFICATIONS=1 environment variable for your Meteor application server process, and the package will then configure this for you:



Just like Meteor.Collection with Mongo, you will work with Meteor.RedisCollection for Redis data.

You can instantiate a RedisCollection on both client and on the server. The collection can be either unnamed (unmanaged, just in-memory) or must be "redis" as Redis doesn't have any concept of namespaced collections.

var redisCollection = new Meteor.RedisCollection("redis");

The collection wraps the Redis commands. If a callback is passed then the commands execute asynchronously. If no callback is passed, on the server, the call is executed synchronously (technically this uses fibers and only appears to be synchronous, so it does not block the event-loop). If you're on the client and don't pass a callback, the call executes asynchronously and you won't be notified of the result.


One can publish a cursor just like in mongo-livedata. The Redis equivalent of 'find' is 'matching', which matches keys using Redis pattern matching syntax.

Meteor.publish("peter-things", function () {
  return redisCollection.matching("peter-things-*");

This way data will be automatically synchronized to all subscribed clients.

Latency compensation

Latency compensation works with all supported commands used either at the client or client's simulations.

Permissions: allow/deny

Because redis has so many commands, unlike mongo-livedata all commands go through one allow/deny callback method: exec.

// allow only 'incr' calls on keys starting with 'peter-things-'
  exec: function (userId, command, args) {
    if (command !== 'incr') return false;
    if (_.any(args, function (key) { return key.substr(0, 13) !== "peter-things-"; }))
      return false;
    return true;

Supported commands

Right now only commands related to keys and strings are supported (but not binary operations) and Hashes. Sets, ordered sets and other are not currently supported.

Flushall does not currently work, because Redis doesn't send a keyspace notification.

Known Issues

Right now it is known that the following things don't work:

  • publishing an array of cursors (create several separate publishes instead)
  • flushall is not noticed
  • no support for sets, ordered sets, lists, hyperloglog, etc


MIT (c) Meteor Development Group