Skip to content

Breaking changes between v1 and v2

Zihua 子骅 edited this page Jun 13, 2016 · 3 revisions

Authentication related errors are emited with "error" event, instead of "authError" event

v1:

redis.on('authError', function () {});

v2:

redis.on('error', function () {});

Reply transformers will be applied for transactions.

v1:

redis.multi().hegetall('hashkey').exec();
// result for hgetall is ["a", "1", "b", "2"]

v2:

redis.multi().hegetall('hashkey').exec();
// result for hgetall is { a: "1", b: "2" }

Pipeline#execBuffer() is deprecated. Use Pipeline#exec() instead.

This result format (either string or buffer) for each command inside a pipeline (or a transaction) is decided by the command itself (with or without the Buffer postfix) instead of the last exec and execBuffer.

v1:

redis.multi().set('foo', 'bar').getBuffer('foo').exec(console.log);
// null [ [ null, 'OK' ], [ null, 'bar' ] ]
redis.multi().set('foo', 'bar').getBuffer('foo').execBuffer(console.log);
// null [ [ null, <Buffer 4f 4b> ], [ null, <Buffer 62 61 72> ] ]

v2:

redis.multi().set('foo', 'bar').getBuffer('foo').exec(console.log);
// null [ [ null, 'OK' ], [ null, <Buffer 62 61 72> ] ]
redis.multi().set('foo', 'bar').getBuffer('foo').execBuffer(console.log); // deprecated
// null [ [ null, 'OK' ], [ null, <Buffer 62 61 72> ] ]

Cluster related changes:

  1. Cluster#masterNodes and Cluster#nodes is removed. Use Cluster#nodes('masters') and Cluster#nodes('all') instead.
  2. Cluster#to() is removed. Use Promise.all(Cluster#nodes().map(function (node) {})) instead.
  3. Option readOnly is removed. Check out scaleReads option.
  4. Per-instance config passed to each Redis instance should be specified with the redisOptions property of the cluster option.