You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Support ZINTERCARD and SINTERCARD (#2040)
* Support ZINTERCARD and SINTERCARD * clean code * clean code Co-authored-by: leibale <leibale1998@gmail.com>
This commit is contained in:
@@ -98,6 +98,7 @@ import * as SETEX from '../commands/SETEX';
|
||||
import * as SETNX from '../commands/SETNX';
|
||||
import * as SETRANGE from '../commands/SETRANGE';
|
||||
import * as SINTER from '../commands/SINTER';
|
||||
import * as SINTERCARD from '../commands/SINTERCARD';
|
||||
import * as SINTERSTORE from '../commands/SINTERSTORE';
|
||||
import * as SISMEMBER from '../commands/SISMEMBER';
|
||||
import * as SMEMBERS from '../commands/SMEMBERS';
|
||||
@@ -149,6 +150,7 @@ import * as ZDIFFSTORE from '../commands/ZDIFFSTORE';
|
||||
import * as ZINCRBY from '../commands/ZINCRBY';
|
||||
import * as ZINTER_WITHSCORES from '../commands/ZINTER_WITHSCORES';
|
||||
import * as ZINTER from '../commands/ZINTER';
|
||||
import * as ZINTERCARD from '../commands/ZINTERCARD';
|
||||
import * as ZINTERSTORE from '../commands/ZINTERSTORE';
|
||||
import * as ZLEXCOUNT from '../commands/ZLEXCOUNT';
|
||||
import * as ZMSCORE from '../commands/ZMSCORE';
|
||||
@@ -366,6 +368,8 @@ export default {
|
||||
sDiffStore: SDIFFSTORE,
|
||||
SINTER,
|
||||
sInter: SINTER,
|
||||
SINTERCARD,
|
||||
sInterCard: SINTERCARD,
|
||||
SINTERSTORE,
|
||||
sInterStore: SINTERSTORE,
|
||||
SET,
|
||||
@@ -478,6 +482,8 @@ export default {
|
||||
zInterWithScores: ZINTER_WITHSCORES,
|
||||
ZINTER,
|
||||
zInter: ZINTER,
|
||||
ZINTERCARD,
|
||||
zInterCard: ZINTERCARD,
|
||||
ZINTERSTORE,
|
||||
zInterStore: ZINTERSTORE,
|
||||
ZLEXCOUNT,
|
||||
|
30
packages/client/lib/commands/SINTERCARD.spec.ts
Normal file
30
packages/client/lib/commands/SINTERCARD.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './SINTERCARD';
|
||||
|
||||
describe('SINTERCARD', () => {
|
||||
testUtils.isVersionGreaterThanHook([7, 0]);
|
||||
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(['1', '2']),
|
||||
['SINTERCARD', '2', '1', '2']
|
||||
);
|
||||
});
|
||||
|
||||
it('with limit', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(['1', '2'], 1),
|
||||
['SINTERCARD', '2', '1', '2', 'LIMIT', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.sInterCard', async client => {
|
||||
assert.deepEqual(
|
||||
await client.sInterCard('key'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
21
packages/client/lib/commands/SINTERCARD.ts
Normal file
21
packages/client/lib/commands/SINTERCARD.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(
|
||||
keys: Array<RedisCommandArgument> | RedisCommandArgument,
|
||||
limit?: number
|
||||
): RedisCommandArguments {
|
||||
const args = pushVerdictArgument(['SINTERCARD'], keys);
|
||||
|
||||
if (limit) {
|
||||
args.push('LIMIT', limit.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
30
packages/client/lib/commands/ZINTERCARD.spec.ts
Normal file
30
packages/client/lib/commands/ZINTERCARD.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './ZINTERCARD';
|
||||
|
||||
describe('ZINTERCARD', () => {
|
||||
testUtils.isVersionGreaterThanHook([7, 0]);
|
||||
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(['1', '2']),
|
||||
['ZINTERCARD', '2', '1', '2']
|
||||
);
|
||||
});
|
||||
|
||||
it('with limit', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(['1', '2'], 1),
|
||||
['ZINTERCARD', '2', '1', '2', 'LIMIT', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.zInterCard', async client => {
|
||||
assert.deepEqual(
|
||||
await client.zInterCard('key'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
21
packages/client/lib/commands/ZINTERCARD.ts
Normal file
21
packages/client/lib/commands/ZINTERCARD.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(
|
||||
keys: Array<RedisCommandArgument> | RedisCommandArgument,
|
||||
limit?: number
|
||||
): RedisCommandArguments {
|
||||
const args = pushVerdictArgument(['ZINTERCARD'], keys);
|
||||
|
||||
if (limit) {
|
||||
args.push('LIMIT', limit.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
Reference in New Issue
Block a user