Skip to content

Commit

Permalink
Fix mset transformer not supporting keyPrefix. Close #217
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Dec 20, 2015
1 parent 4086347 commit 05a61e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- redis-server

script:
- npm run test:cov || npm run test:cov
- npm run test:cov || npm run test:cov || npm run test:cov

env:
- CXX=g++-4.8 INSTALL_HIREDIS="yes"
Expand Down
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is a manually maintained list of changes for each release. Feel free t

## Master Branch (Unreleased)

* Fix `mset` transformer not supporting keyPrefix ([#217](https://github.com/luin/ioredis/issues/217)).

## v.1.13.0 - December 13, 2015

* [Cluster] Select a random node when the target node is closed.
Expand Down
5 changes: 3 additions & 2 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ function Command(name, args, options, callback) {
this.replyEncoding = options.replyEncoding;
this.errorStack = options.errorStack;
this.args = args ? _.flatten(args) : [];
this.callback = callback;
this.initPromise();

var keyPrefix = options.keyPrefix;
if (keyPrefix) {
this._iterateKeys(function (key) {
return keyPrefix + key;
});
}
this.callback = callback;
this.initPromise();
}

Command.prototype.initPromise = function () {
Expand Down
11 changes: 11 additions & 0 deletions test/functional/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ describe('transformer', function () {
});
});
});
it('should work with keyPrefix option', function (done) {
var redis = new Redis({ keyPrefix: 'foo:' });
redis.mset({ a: 1, b: '2' }, function (err, result) {
expect(result).to.eql('OK');
var otherRedis = new Redis();
otherRedis.mget('foo:a', 'foo:b', function (err, result) {
expect(result).to.eql(['1', '2']);
done();
});
});
});
});

describe('hgetall', function () {
Expand Down

0 comments on commit 05a61e1

Please sign in to comment.