You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
fix #1650 - add support for Buffer in some commands, add GET_BUFFER command
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export function transformArguments(username: string | Array<string>): Array<string> {
|
||||
export function transformArguments(username: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['ACL', 'DELUSER'], username);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyString } from './generic-transformers';
|
||||
|
||||
export function transformArguments(username: string, rule: string | Array<string>): Array<string> {
|
||||
export function transformArguments(username: string, rule: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['ACL', 'SETUSER', username], rule);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
type BitOperations = 'AND' | 'OR' | 'XOR' | 'NOT';
|
||||
|
||||
export function transformArguments(operation: BitOperations, destKey: string, key: string | Array<string>): Array<string> {
|
||||
export function transformArguments(operation: BitOperations, destKey: string, key: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['BITOP', operation, destKey], key);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>, timeout: number): Array<string> {
|
||||
export function transformArguments(keys: string | Buffer | Array<string | Buffer>, timeout: number): TransformArgumentsReply {
|
||||
const args = pushVerdictArguments(['BLPOP'], keys);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): TransformArgumentsReply {
|
||||
const args = pushVerdictArguments(['BRPOP'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): TransformArgumentsReply {
|
||||
const args = pushVerdictArguments(['BZPOPMAX'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): TransformArgumentsReply {
|
||||
const args = pushVerdictArguments(['BZPOPMIN'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['DEL'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyBoolean } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['EXISTS'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['GEOHASH', key], member);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['GEOPOS', key], member);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { transformReplyString } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: string | Buffer): TransformArgumentsReply {
|
||||
return ['GET', key];
|
||||
}
|
||||
|
||||
|
22
lib/commands/GET_BUFFER.spec.ts
Normal file
22
lib/commands/GET_BUFFER.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
|
||||
describe('GET_BUFFER', () => {
|
||||
itWithClient(TestRedisServers.OPEN, 'client.getBuffer', async client => {
|
||||
const buffer = Buffer.from('string');
|
||||
await client.set('key', buffer);
|
||||
assert.deepEqual(
|
||||
buffer,
|
||||
await client.getBuffer('key')
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.getBuffer', async cluster => {
|
||||
const buffer = Buffer.from('string');
|
||||
await cluster.set('key', buffer);
|
||||
assert.deepEqual(
|
||||
buffer,
|
||||
await cluster.getBuffer('key')
|
||||
);
|
||||
});
|
||||
});
|
7
lib/commands/GET_BUFFER.ts
Normal file
7
lib/commands/GET_BUFFER.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { transformReplyBuffer } from './generic-transformers';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY, transformArguments } from './GET';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export const transformReply = transformReplyBuffer;
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, field: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['HDEL', key], field);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, fields: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, fields: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['HMGET', key], fields);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, elements: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, elements: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['LPUSH', key], elements);}
|
||||
|
||||
export const transformReply = transformReplyNumber;
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['LPUSHX', key], element);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyBoolean } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['PFADD', key], element);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['PFCOUNT'], key);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyString } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, source: string | Array<string>): Array<string> {
|
||||
export function transformArguments(destination: string, source: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['PFMERGE', destination], source);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['RPUSH', key], element);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['RPUSHX', key], element);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, members: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, members: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SADD', key], members);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyBooleanArray } from './generic-transformers';
|
||||
|
||||
export function transformArguments(sha1: string | Array<string>): Array<string> {
|
||||
export function transformArguments(sha1: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SCRIPT', 'EXISTS'], sha1);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SDIFF'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SDIFFSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@@ -106,7 +106,7 @@ describe('SET', () => {
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
itWithClient(TestRedisServers.OPEN, 'with GET on empty key', async client => {
|
||||
assert.equal(
|
||||
await client.set('key', 'value', {
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
interface EX {
|
||||
@@ -38,7 +40,7 @@ interface SetCommonOptions {
|
||||
|
||||
type SetOptions = SetTTL & SetGuards & (SetCommonOptions | {});
|
||||
|
||||
export function transformArguments(key: string, value: string, options?: SetOptions): Array<string> {
|
||||
export function transformArguments(key: string | Buffer, value: string | Buffer, options?: SetOptions): TransformArgumentsReply {
|
||||
const args = ['SET', key, value];
|
||||
|
||||
if (!options) {
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { transformReplyString } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, seconds: number, value: string): Array<string> {
|
||||
export function transformArguments(key: string | Buffer, seconds: number, value: string): TransformArgumentsReply {
|
||||
return [
|
||||
'SETEX',
|
||||
key,
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SINTER'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SINTERSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, members: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, members: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SREM', key], members);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SUNION'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): Array<string> {
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['SUNIONSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['TOUCH'], key);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['UNLINK'], key);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyString } from './generic-transformers';
|
||||
|
||||
export function transformArguments(key: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['WATCH'], key);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, group: string, id: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, group: string, id: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['XACK', key, group], id);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, id: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, id: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['XDEL', key], id);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArgument, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: Array<string> | string): Array<string> {
|
||||
export function transformArguments(keys: Array<string> | string): TransformArgumentsReply {
|
||||
return pushVerdictArgument(['ZDIFF'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArgument, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: Array<string> | string): Array<string> {
|
||||
export function transformArguments(destination: string, keys: Array<string> | string): TransformArgumentsReply {
|
||||
return pushVerdictArgument(['ZDIFFSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { transformArguments as transformZDiffArguments } from './ZDIFF';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZDIFF';
|
||||
|
||||
export function transformArguments(...args: Parameters<typeof transformZDiffArguments>): Array<string> {
|
||||
export function transformArguments(...args: Parameters<typeof transformZDiffArguments>): TransformArgumentsReply {
|
||||
return [
|
||||
...transformZDiffArguments(...args),
|
||||
'WITHSCORES'
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArgument, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
@@ -9,7 +10,7 @@ interface ZInterOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZInterOptions): Array<string> {
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZInterOptions): TransformArgumentsReply {
|
||||
const args = pushVerdictArgument(['ZINTER'], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArgument, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@@ -7,7 +8,7 @@ interface ZInterStoreOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZInterStoreOptions): Array<string> {
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZInterStoreOptions): TransformArgumentsReply {
|
||||
const args = pushVerdictArgument(['ZINTERSTORE', destination], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { transformArguments as transformZInterArguments } from './ZINTER';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZINTER';
|
||||
|
||||
export function transformArguments(...args: Parameters<typeof transformZInterArguments>): Array<string> {
|
||||
export function transformArguments(...args: Parameters<typeof transformZInterArguments>): TransformArgumentsReply {
|
||||
return [
|
||||
...transformZInterArguments(...args),
|
||||
'WITHSCORES'
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinityNullArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['ZMSCORE', key], member);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): Array<string> {
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
return pushVerdictArguments(['ZREM', key], member);
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArgument, transformReplyStringArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
@@ -9,7 +10,7 @@ interface ZUnionOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZUnionOptions): Array<string> {
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZUnionOptions): TransformArgumentsReply {
|
||||
const args = pushVerdictArgument(['ZUNION'], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { pushVerdictArgument, transformReplyNumber } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@@ -7,7 +8,7 @@ interface ZUnionOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZUnionOptions): Array<string> {
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZUnionOptions): TransformArgumentsReply {
|
||||
const args = pushVerdictArgument(['ZUNIONSTORE', destination], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { transformArguments as transformZUnionArguments } from './ZUNION';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZUNION';
|
||||
|
||||
export function transformArguments(...args: Parameters<typeof transformZUnionArguments>): Array<string> {
|
||||
export function transformArguments(...args: Parameters<typeof transformZUnionArguments>): TransformArgumentsReply {
|
||||
return [
|
||||
...transformZUnionArguments(...args),
|
||||
'WITHSCORES'
|
||||
|
@@ -20,6 +20,10 @@ export function transformReplyString(reply: string): string {
|
||||
return reply;
|
||||
}
|
||||
|
||||
export function transformReplyBuffer(reply: Buffer): Buffer {
|
||||
return reply;
|
||||
}
|
||||
|
||||
export function transformReplyStringNull(reply: string | null): string | null {
|
||||
return reply;
|
||||
}
|
||||
@@ -352,11 +356,11 @@ export function pushStringTuplesArguments(args: Array<string>, tuples: StringTup
|
||||
return args;
|
||||
}
|
||||
|
||||
export function pushVerdictArguments(args: TransformArgumentsReply, value: string | Array<string>): TransformArgumentsReply {
|
||||
if (typeof value === 'string') {
|
||||
args.push(value);
|
||||
} else {
|
||||
export function pushVerdictArguments(args: TransformArgumentsReply, value: string | Buffer | Array<string | Buffer>): TransformArgumentsReply {
|
||||
if (Array.isArray(value)) {
|
||||
args.push(...value);
|
||||
} else {
|
||||
args.push(value);
|
||||
}
|
||||
|
||||
return args;
|
||||
|
@@ -61,6 +61,7 @@ import * as GEOPOS from './GEOPOS';
|
||||
import * as GEOSEARCH_WITH from './GEOSEARCH_WITH';
|
||||
import * as GEOSEARCH from './GEOSEARCH';
|
||||
import * as GEOSEARCHSTORE from './GEOSEARCHSTORE';
|
||||
import * as GET_BUFFER from './GET_BUFFER';
|
||||
import * as GET from './GET';
|
||||
import * as GETBIT from './GETBIT';
|
||||
import * as GETDEL from './GETDEL';
|
||||
@@ -370,6 +371,8 @@ export default {
|
||||
geoSearch: GEOSEARCH,
|
||||
GEOSEARCHSTORE,
|
||||
geoSearchStore: GEOSEARCHSTORE,
|
||||
GET_BUFFER,
|
||||
getBuffer: GET_BUFFER,
|
||||
GET,
|
||||
get: GET,
|
||||
GETBIT,
|
||||
@@ -733,15 +736,16 @@ export default {
|
||||
zUnionStore: ZUNIONSTORE
|
||||
};
|
||||
|
||||
export type RedisReply = string | number | Array<RedisReply> | null | undefined;
|
||||
export type RedisReply = string | number | Buffer | Array<RedisReply> | null | undefined;
|
||||
|
||||
export type TransformArgumentsReply = Array<string> & { preserve?: unknown };
|
||||
export type TransformArgumentsReply = Array<string | Buffer> & { preserve?: unknown };
|
||||
|
||||
export interface RedisCommand {
|
||||
FIRST_KEY_INDEX?: number | ((...args: Array<any>) => string);
|
||||
IS_READ_ONLY?: boolean;
|
||||
transformArguments(...args: Array<any>): TransformArgumentsReply;
|
||||
transformReply(reply: RedisReply, preserved: unknown): any;
|
||||
BUFFER_MODE?: boolean;
|
||||
transformReply(reply: RedisReply, preserved?: unknown): any;
|
||||
}
|
||||
|
||||
export interface RedisCommands {
|
||||
|
Reference in New Issue
Block a user