Skip to content

Commit

Permalink
feat: add unlink command (stipsan#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnarHolwerda authored and stipsan committed May 13, 2019
1 parent 3b36191 commit 6ef180a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
| [touch](http://redis.io/commands/TOUCH) | :white_check_mark: | :x: |
| [ttl](http://redis.io/commands/TTL) | :white_check_mark: | :white_check_mark: |
| [type](http://redis.io/commands/TYPE) | :white_check_mark: | :white_check_mark: |
| [unlink](http://redis.io/commands/UNLINK) | :white_check_mark: | :white_check_mark: |
| [unsubscribe](http://redis.io/commands/UNSUBSCRIBE) | :white_check_mark: | :white_check_mark: |
| [unwatch](http://redis.io/commands/UNWATCH) | :white_check_mark: | :x: |
| [wait](http://redis.io/commands/WAIT) | :white_check_mark: | :x: |
Expand Down
1 change: 1 addition & 0 deletions src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export * from './time';
export * from './ttl';
export * from './type';
export * from './unsubscribe';
export * from './unlink';
export * from './xadd';
export * from './xlen';
export * from './xrange';
Expand Down
6 changes: 6 additions & 0 deletions src/commands/unlink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { del } from './del';

export function unlink(...keys) {
const removeKeys = del.bind(this);
return removeKeys(...keys);
}
20 changes: 20 additions & 0 deletions test/commands/unlink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import expect from 'expect';

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

describe('unlink', () => {
const redis = new MockRedis({
data: {
unlinkme: 'please',
metoo: 'pretty please',
},
});
it('should unlink/delete passed in keys', () =>
redis
.unlink('unlinkme', 'metoo')
.then(status => expect(status).toBe(2))
.then(() => expect(redis.data.has('unlinkme')).toBe(false))
.then(() => expect(redis.data.has('metoo')).toBe(false)));
it('should return the number of keys unlinked', () =>
redis.unlink('deleteme', 'metoo').then(status => expect(status).toBe(0)));
});

0 comments on commit 6ef180a

Please sign in to comment.