Skip to content

Commit

Permalink
add mget (#134)
Browse files Browse the repository at this point in the history
Awesome, I'll add you :)
  • Loading branch information
stipsan authored Sep 25, 2016
1 parent 00ec22f commit f2d28cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './keys';
export * from './llen';
export * from './lpush';
export * from './lrem';
export * from './mget';
export * from './publish';
export * from './rename';
export * from './rpoplpush';
Expand Down
3 changes: 3 additions & 0 deletions src/commands/mget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function mget(keys) {
return keys.map(key => ({}.hasOwnProperty.call(this.data, key) ? this.data[key] : null));
}
21 changes: 21 additions & 0 deletions test/commands/mget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import expect from 'expect';

import MockRedis from '../../src';

describe('mget', () => {
it('should return null on keys that do not exist', () => {
const redis = new MockRedis();

return redis.mget(['foo']).then(result => expect(result).toEqual([null]));
});

it('should return value keys that exist', () => {
const redis = new MockRedis({
data: {
foo: 'bar',
},
});

return redis.mget(['foo', 'hello']).then(result => expect(result).toEqual(['bar', null]));
});
});

0 comments on commit f2d28cb

Please sign in to comment.