You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
buffers, buffers everywhere...
This commit is contained in:
10
README.md
10
README.md
@@ -75,6 +75,16 @@ await client.hGetAll('key'); // { field1: 'value1', field2: 'value2' }
|
||||
await client.hVals('key'); // ['value1', 'value2']
|
||||
```
|
||||
|
||||
`Buffer`s are supported as well:
|
||||
|
||||
```typescript
|
||||
await client.hSet('key', 'field', Buffer.from('value')); // 'OK'
|
||||
await client.hGetAll(
|
||||
commandOptions({ returnBuffers: true }),
|
||||
'key'
|
||||
); // { field: <Buffer 76 61 6c 75 65> }
|
||||
```
|
||||
|
||||
### Unsupported Redis Commands
|
||||
|
||||
If you want to run commands and/or use arguments that Node Redis doesn't know about (yet!) use `.sendCommand()`:
|
||||
|
1847
package-lock.json
generated
1847
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -5,6 +5,9 @@
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"workspaces": [
|
||||
"./packages/*"
|
||||
],
|
||||
@@ -29,8 +32,7 @@
|
||||
"@tsconfig/node12": "^1.0.9",
|
||||
"gh-pages": "^3.2.3",
|
||||
"release-it": "^14.11.8",
|
||||
"typedoc": "^0.22.10",
|
||||
"typescript": "^4.5.3"
|
||||
"typescript": "^4.5.4"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -40,10 +42,8 @@
|
||||
"url": "https://github.com/redis/node-redis/issues"
|
||||
},
|
||||
"homepage": "https://github.com/redis/node-redis",
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"engines": {
|
||||
"npm": ">=7"
|
||||
"npm": ">=7",
|
||||
"typescript": ">=4"
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ export interface QueueCommandOptions {
|
||||
asap?: boolean;
|
||||
chainId?: symbol;
|
||||
signal?: AbortSignal;
|
||||
returnBuffers?: boolean;
|
||||
ignorePubSubMode?: boolean;
|
||||
}
|
||||
|
||||
@@ -27,7 +28,7 @@ interface CommandWaitingForReply {
|
||||
resolve(reply?: unknown): void;
|
||||
reject(err: Error): void;
|
||||
channelsCounter?: number;
|
||||
bufferMode?: boolean;
|
||||
returnBuffers?: boolean;
|
||||
}
|
||||
|
||||
export enum PubSubSubscribeCommands {
|
||||
@@ -41,8 +42,8 @@ export enum PubSubUnsubscribeCommands {
|
||||
}
|
||||
|
||||
export type PubSubListener<
|
||||
BUFFER_MODE extends boolean = false,
|
||||
T = BUFFER_MODE extends true ? Buffer : string
|
||||
RETURN_BUFFERS extends boolean = false,
|
||||
T = RETURN_BUFFERS extends true ? Buffer : string
|
||||
> = (message: T, channel: T) => unknown;
|
||||
|
||||
interface PubSubListeners {
|
||||
@@ -142,7 +143,7 @@ export default class RedisCommandsQueue {
|
||||
this.#maxLength = maxLength;
|
||||
}
|
||||
|
||||
addCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: QueueCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
addCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: QueueCommandOptions): Promise<T> {
|
||||
if (this.#pubSubState && !options?.ignorePubSubMode) {
|
||||
return Promise.reject(new Error('Cannot send commands in PubSub mode'));
|
||||
} else if (this.#maxLength && this.#waitingToBeSent.length + this.#waitingForReply.length >= this.#maxLength) {
|
||||
@@ -154,7 +155,7 @@ export default class RedisCommandsQueue {
|
||||
const node = new LinkedList.Node<CommandWaitingToBeSent>({
|
||||
args,
|
||||
chainId: options?.chainId,
|
||||
bufferMode,
|
||||
returnBuffers: options?.returnBuffers,
|
||||
resolve,
|
||||
reject
|
||||
});
|
||||
@@ -197,7 +198,7 @@ export default class RedisCommandsQueue {
|
||||
command: PubSubSubscribeCommands,
|
||||
channels: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||
listener: PubSubListener<T>,
|
||||
bufferMode?: T
|
||||
returnBuffers?: T
|
||||
): Promise<void> {
|
||||
const pubSubState = this.#initiatePubSubState(),
|
||||
channelsToSubscribe: Array<RedisCommandArgument> = [],
|
||||
@@ -215,7 +216,7 @@ export default class RedisCommandsQueue {
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/23132
|
||||
(bufferMode ? listeners.buffers : listeners.strings).add(listener as any);
|
||||
(returnBuffers ? listeners.buffers : listeners.strings).add(listener as any);
|
||||
}
|
||||
|
||||
if (!channelsToSubscribe.length) {
|
||||
@@ -228,7 +229,7 @@ export default class RedisCommandsQueue {
|
||||
command: PubSubUnsubscribeCommands,
|
||||
channels?: string | Array<string>,
|
||||
listener?: PubSubListener<T>,
|
||||
bufferMode?: T
|
||||
returnBuffers?: T
|
||||
): Promise<void> {
|
||||
if (!this.#pubSubState) {
|
||||
return Promise.resolve();
|
||||
@@ -252,7 +253,7 @@ export default class RedisCommandsQueue {
|
||||
let shouldUnsubscribe;
|
||||
if (listener) {
|
||||
// https://github.com/microsoft/TypeScript/issues/23132
|
||||
(bufferMode ? sets.buffers : sets.strings).delete(listener as any);
|
||||
(returnBuffers ? sets.buffers : sets.strings).delete(listener as any);
|
||||
shouldUnsubscribe = !sets.buffers.size && !sets.strings.size;
|
||||
} else {
|
||||
shouldUnsubscribe = true;
|
||||
@@ -289,7 +290,7 @@ export default class RedisCommandsQueue {
|
||||
this.#waitingToBeSent.push({
|
||||
args: commandArgs,
|
||||
channelsCounter,
|
||||
bufferMode: true,
|
||||
returnBuffers: true,
|
||||
resolve: () => {
|
||||
pubSubState[inProgressKey] -= channelsCounter;
|
||||
if (isSubscribe) {
|
||||
@@ -350,7 +351,7 @@ export default class RedisCommandsQueue {
|
||||
resolve: toSend.resolve,
|
||||
reject: toSend.reject,
|
||||
channelsCounter: toSend.channelsCounter,
|
||||
bufferMode: toSend.bufferMode
|
||||
returnBuffers: toSend.returnBuffers
|
||||
});
|
||||
}
|
||||
this.#chainInExecution = toSend?.chainId;
|
||||
@@ -359,7 +360,7 @@ export default class RedisCommandsQueue {
|
||||
|
||||
parseResponse(data: Buffer): void {
|
||||
this.#parser.setReturnBuffers(
|
||||
!!this.#waitingForReply.head?.value.bufferMode ||
|
||||
!!this.#waitingForReply.head?.value.returnBuffers ||
|
||||
!!this.#pubSubState?.subscribed
|
||||
);
|
||||
this.#parser.execute(data);
|
||||
|
@@ -319,9 +319,11 @@ describe('Client', () => {
|
||||
assert.equal(await client.sendCommand(['PING']), 'PONG');
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithClient('bufferMode', async client => {
|
||||
testUtils.testWithClient('returnBuffers', async client => {
|
||||
assert.deepEqual(
|
||||
await client.sendCommand(['PING'], undefined, true),
|
||||
await client.sendCommand(['PING'], RedisClient.commandOptions({
|
||||
returnBuffers: true
|
||||
}),),
|
||||
Buffer.from('PONG')
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
@@ -435,10 +437,10 @@ describe('Client', () => {
|
||||
});
|
||||
|
||||
testUtils.testWithClient('modules', async client => {
|
||||
assert.equal(
|
||||
await client.module.echo('message'),
|
||||
'message'
|
||||
);
|
||||
// assert.equal(
|
||||
// await client.module.echo('message'),
|
||||
// 'message'
|
||||
// );
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
@@ -551,7 +553,7 @@ describe('Client', () => {
|
||||
|
||||
await client.zAdd('key', members);
|
||||
|
||||
const map = new Map();
|
||||
const map = new Map<string, number>();
|
||||
for await (const member of client.zScanIterator('key')) {
|
||||
map.set(member.value, member.score);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import COMMANDS from './commands';
|
||||
import { RedisCommand, RedisCommandArguments, RedisCommandRawReply, RedisCommandReply, RedisModules, RedisPlugins, RedisScript, RedisScripts } from '../commands';
|
||||
import { RedisCommand, RedisCommandArgument, RedisCommandArguments, RedisCommandRawReply, RedisCommandReply, RedisModules, RedisPlugins, RedisScript, RedisScripts } from '../commands';
|
||||
import RedisSocket, { RedisSocketOptions, RedisTlsSocketOptions } from './socket';
|
||||
import RedisCommandsQueue, { PubSubListener, PubSubSubscribeCommands, PubSubUnsubscribeCommands, QueueCommandOptions } from './commands-queue';
|
||||
import RedisClientMultiCommand, { RedisClientMultiCommandType } from './multi-command';
|
||||
@@ -28,8 +28,30 @@ export interface RedisClientOptions<M extends RedisModules, S extends RedisScrip
|
||||
isolationPoolOptions?: PoolOptions;
|
||||
}
|
||||
|
||||
export type RedisClientCommandSignature<C extends RedisCommand> =
|
||||
(...args: Parameters<C['transformArguments']> | [options: CommandOptions<ClientCommandOptions>, ...rest: Parameters<C['transformArguments']>]) => Promise<RedisCommandReply<C>>;
|
||||
type ConvertArgumentType<Type, ToType> =
|
||||
Type extends RedisCommandArgument ? (
|
||||
Type extends (string & ToType) ? Type : ToType
|
||||
) : (
|
||||
Type extends Set<infer Member> ? Set<ConvertArgumentType<Member, ToType>> : (
|
||||
Type extends Map<infer Key, infer Value> ? Map<Key, ConvertArgumentType<Value, ToType>> : (
|
||||
Type extends Record<keyof any, any> ? {
|
||||
[Property in keyof Type]: ConvertArgumentType<Type[Property], ToType>
|
||||
} : Type
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
export type RedisClientCommandSignature<
|
||||
Command extends RedisCommand,
|
||||
Params extends Array<unknown> = Parameters<Command['transformArguments']>
|
||||
> = <Options extends CommandOptions<ClientCommandOptions>>(
|
||||
...args: Params | [options: Options, ...rest: Params]
|
||||
) => Promise<
|
||||
ConvertArgumentType<
|
||||
RedisCommandReply<Command>,
|
||||
Options['returnBuffers'] extends true ? Buffer : string
|
||||
>
|
||||
>;
|
||||
|
||||
type WithCommands = {
|
||||
[P in keyof typeof COMMANDS]: RedisClientCommandSignature<(typeof COMMANDS)[P]>;
|
||||
@@ -59,7 +81,7 @@ type ClientLegacyCallback = (err: Error | null, reply?: RedisCommandRawReply) =>
|
||||
|
||||
export type ClientLegacyCommandArguments = LegacyCommandArguments | [...LegacyCommandArguments, ClientLegacyCallback];
|
||||
export default class RedisClient<M extends RedisModules, S extends RedisScripts> extends EventEmitter {
|
||||
static commandOptions(options: ClientCommandOptions): CommandOptions<ClientCommandOptions> {
|
||||
static commandOptions<T extends ClientCommandOptions>(options: T): CommandOptions<T> {
|
||||
return commandOptions(options);
|
||||
}
|
||||
|
||||
@@ -325,17 +347,17 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
|
||||
return transformCommandReply(
|
||||
command,
|
||||
await this.#sendCommand(redisArgs, options, command.BUFFER_MODE),
|
||||
await this.#sendCommand(redisArgs, options),
|
||||
redisArgs.preserve
|
||||
);
|
||||
}
|
||||
|
||||
sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
return this.#sendCommand(args, options, bufferMode);
|
||||
sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions): Promise<T> {
|
||||
return this.#sendCommand(args, options);
|
||||
}
|
||||
|
||||
// using `#sendCommand` cause `sendCommand` is overwritten in legacy mode
|
||||
#sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
#sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions): Promise<T> {
|
||||
if (!this.#socket.isOpen) {
|
||||
return Promise.reject(new ClientClosedError());
|
||||
}
|
||||
@@ -349,7 +371,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
);
|
||||
}
|
||||
|
||||
const promise = this.#queue.addCommand<T>(args, options, bufferMode);
|
||||
const promise = this.#queue.addCommand<T>(args, options);
|
||||
this.#tick();
|
||||
return promise;
|
||||
}
|
||||
@@ -359,19 +381,19 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
|
||||
return transformCommandReply(
|
||||
script,
|
||||
await this.executeScript(script, redisArgs, options, script.BUFFER_MODE),
|
||||
await this.executeScript(script, redisArgs, options),
|
||||
redisArgs.preserve
|
||||
);
|
||||
}
|
||||
|
||||
async executeScript(script: RedisScript, args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<RedisCommandReply<typeof script>> {
|
||||
async executeScript(script: RedisScript, args: RedisCommandArguments, options?: ClientCommandOptions): Promise<RedisCommandReply<typeof script>> {
|
||||
try {
|
||||
return await this.#sendCommand([
|
||||
'EVALSHA',
|
||||
script.SHA1,
|
||||
script.NUMBER_OF_KEYS.toString(),
|
||||
...args
|
||||
], options, bufferMode);
|
||||
], options);
|
||||
} catch (err: any) {
|
||||
if (!err?.message?.startsWith?.('NOSCRIPT')) {
|
||||
throw err;
|
||||
@@ -382,7 +404,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
script.SCRIPT,
|
||||
script.NUMBER_OF_KEYS.toString(),
|
||||
...args
|
||||
], options, bufferMode);
|
||||
], options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +575,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
} while (cursor !== 0);
|
||||
}
|
||||
|
||||
async* hScanIterator(key: string, options?: ScanOptions): AsyncIterable<HScanTuple> {
|
||||
async* hScanIterator(key: string, options?: ScanOptions): AsyncIterable<ConvertArgumentType<HScanTuple, string>> {
|
||||
let cursor = 0;
|
||||
do {
|
||||
const reply = await (this as any).hScan(key, cursor, options);
|
||||
@@ -575,7 +597,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
} while (cursor !== 0);
|
||||
}
|
||||
|
||||
async* zScanIterator(key: string, options?: ScanOptions): AsyncIterable<ZMember<string>> {
|
||||
async* zScanIterator(key: string, options?: ScanOptions): AsyncIterable<ConvertArgumentType<ZMember, string>> {
|
||||
let cursor = 0;
|
||||
do {
|
||||
const reply = await (this as any).zScan(key, cursor, options);
|
||||
|
@@ -4,13 +4,9 @@ import * as BITCOUNT from '../commands/BITCOUNT';
|
||||
import * as BITFIELD from '../commands/BITFIELD';
|
||||
import * as BITOP from '../commands/BITOP';
|
||||
import * as BITPOS from '../commands/BITPOS';
|
||||
import * as BLMOVE_BUFFER from '../commands/BLMOVE_BUFFER';
|
||||
import * as BLMOVE from '../commands/BLMOVE';
|
||||
import * as BLPOP_BUFFER from '../commands/BLPOP_BUFFER';
|
||||
import * as BLPOP from '../commands/BLPOP';
|
||||
import * as BRPOP_BUFFER from '../commands/BRPOP_BUFFER';
|
||||
import * as BRPOP from '../commands/BRPOP';
|
||||
import * as BRPOPLPUSH_BUFFER from '../commands/BRPOPLPUSH_BUFFER';
|
||||
import * as BRPOPLPUSH from '../commands/BRPOPLPUSH';
|
||||
import * as BZPOPMAX from '../commands/BZPOPMAX';
|
||||
import * as BZPOPMIN from '../commands/BZPOPMIN';
|
||||
@@ -31,7 +27,6 @@ import * as GEOPOS from '../commands/GEOPOS';
|
||||
import * as GEOSEARCH_WITH from '../commands/GEOSEARCH_WITH';
|
||||
import * as GEOSEARCH from '../commands/GEOSEARCH';
|
||||
import * as GEOSEARCHSTORE from '../commands/GEOSEARCHSTORE';
|
||||
import * as GET_BUFFER from '../commands/GET_BUFFER';
|
||||
import * as GET from '../commands/GET';
|
||||
import * as GETBIT from '../commands/GETBIT';
|
||||
import * as GETDEL from '../commands/GETDEL';
|
||||
@@ -40,16 +35,13 @@ import * as GETRANGE from '../commands/GETRANGE';
|
||||
import * as GETSET from '../commands/GETSET';
|
||||
import * as HDEL from '../commands/HDEL';
|
||||
import * as HEXISTS from '../commands/HEXISTS';
|
||||
import * as HGET_BUFFER from '../commands/HGET_BUFFER';
|
||||
import * as HGET from '../commands/HGET';
|
||||
import * as HGETALL_BUFFER from '../commands/HGETALL_BUFFER';
|
||||
import * as HGETALL from '../commands/HGETALL';
|
||||
import * as HINCRBY from '../commands/HINCRBY';
|
||||
import * as HINCRBYFLOAT from '../commands/HINCRBYFLOAT';
|
||||
import * as HKEYS from '../commands/HKEYS';
|
||||
import * as HLEN from '../commands/HLEN';
|
||||
import * as HMGET from '../commands/HMGET';
|
||||
import * as HRANDFIELD_COUNT_WITHVALUES_BUFFER from '../commands/HRANDFIELD_COUNT_WITHVALUES_BUFFER';
|
||||
import * as HRANDFIELD_COUNT_WITHVALUES from '../commands/HRANDFIELD_COUNT_WITHVALUES';
|
||||
import * as HRANDFIELD_COUNT from '../commands/HRANDFIELD_COUNT';
|
||||
import * as HRANDFIELD from '../commands/HRANDFIELD';
|
||||
@@ -126,12 +118,8 @@ import * as UNLINK from '../commands/UNLINK';
|
||||
import * as WATCH from '../commands/WATCH';
|
||||
import * as XACK from '../commands/XACK';
|
||||
import * as XADD from '../commands/XADD';
|
||||
import * as XAUTOCLAIM_JUSTID_BUFFER from '../commands/XAUTOCLAIM_JUSTID_BUFFER';
|
||||
import * as XAUTOCLAIM_BUFFER from '../commands/XAUTOCLAIM_BUFFER';
|
||||
import * as XAUTOCLAIM_JUSTID from '../commands/XAUTOCLAIM_JUSTID';
|
||||
import * as XAUTOCLAIM from '../commands/XAUTOCLAIM';
|
||||
import * as XCLAIM_JUSTID_BUFFER from '../commands/XCLAIM_JUSTID_BUFFER';
|
||||
import * as XCLAIM_BUFFER from '../commands/XCLAIM_BUFFER';
|
||||
import * as XCLAIM_JUSTID from '../commands/XCLAIM_JUSTID';
|
||||
import * as XCLAIM from '../commands/XCLAIM';
|
||||
import * as XDEL from '../commands/XDEL';
|
||||
@@ -146,13 +134,9 @@ import * as XINFO_STREAM from '../commands/XINFO_STREAM';
|
||||
import * as XLEN from '../commands/XLEN';
|
||||
import * as XPENDING_RANGE from '../commands/XPENDING_RANGE';
|
||||
import * as XPENDING from '../commands/XPENDING';
|
||||
import * as XRANGE_BUFFER from '../commands/XRANGE_BUFFER';
|
||||
import * as XRANGE from '../commands/XRANGE';
|
||||
import * as XREAD_BUFFER from '../commands/XREAD_BUFFER';
|
||||
import * as XREAD from '../commands/XREAD';
|
||||
import * as XREADGROUP_BUFFER from '../commands/XREADGROUP_BUFFER';
|
||||
import * as XREADGROUP from '../commands/XREADGROUP';
|
||||
import * as XREVRANGE_BUFFER from '../commands/XREVRANGE_BUFFER';
|
||||
import * as XREVRANGE from '../commands/XREVRANGE';
|
||||
import * as XTRIM from '../commands/XTRIM';
|
||||
import * as ZADD from '../commands/ZADD';
|
||||
@@ -203,20 +187,12 @@ export default {
|
||||
bitOp: BITOP,
|
||||
BITPOS,
|
||||
bitPos: BITPOS,
|
||||
BLMOVE_BUFFER,
|
||||
blMoveBuffer: BLMOVE_BUFFER,
|
||||
BLMOVE,
|
||||
blMove: BLMOVE,
|
||||
BLPOP_BUFFER,
|
||||
blPopBuffer: BLPOP_BUFFER,
|
||||
BLPOP,
|
||||
blPop: BLPOP,
|
||||
BRPOP_BUFFER,
|
||||
brPopBuffer: BRPOP_BUFFER,
|
||||
BRPOP,
|
||||
brPop: BRPOP,
|
||||
BRPOPLPUSH_BUFFER,
|
||||
brPopLPushBuffer: BRPOPLPUSH_BUFFER,
|
||||
BRPOPLPUSH,
|
||||
brPopLPush: BRPOPLPUSH,
|
||||
BZPOPMAX,
|
||||
@@ -257,8 +233,6 @@ export default {
|
||||
geoSearch: GEOSEARCH,
|
||||
GEOSEARCHSTORE,
|
||||
geoSearchStore: GEOSEARCHSTORE,
|
||||
GET_BUFFER,
|
||||
getBuffer: GET_BUFFER,
|
||||
GET,
|
||||
get: GET,
|
||||
GETBIT,
|
||||
@@ -275,12 +249,8 @@ export default {
|
||||
hDel: HDEL,
|
||||
HEXISTS,
|
||||
hExists: HEXISTS,
|
||||
HGET_BUFFER,
|
||||
hGetBuffer: HGET_BUFFER,
|
||||
HGET,
|
||||
hGet: HGET,
|
||||
HGETALL_BUFFER,
|
||||
hGetAllBuffer: HGETALL_BUFFER,
|
||||
HGETALL,
|
||||
hGetAll: HGETALL,
|
||||
HINCRBY,
|
||||
@@ -293,8 +263,6 @@ export default {
|
||||
hLen: HLEN,
|
||||
HMGET,
|
||||
hmGet: HMGET,
|
||||
HRANDFIELD_COUNT_WITHVALUES_BUFFER,
|
||||
hRandFieldCountWithValuesBuffer: HRANDFIELD_COUNT_WITHVALUES_BUFFER,
|
||||
HRANDFIELD_COUNT_WITHVALUES,
|
||||
hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES,
|
||||
HRANDFIELD_COUNT,
|
||||
@@ -447,20 +415,12 @@ export default {
|
||||
xAck: XACK,
|
||||
XADD,
|
||||
xAdd: XADD,
|
||||
XAUTOCLAIM_JUSTID_BUFFER,
|
||||
xAutoClaimJustIdBuffer: XAUTOCLAIM_JUSTID_BUFFER,
|
||||
XAUTOCLAIM_BUFFER,
|
||||
xAutoClaimBuffer: XAUTOCLAIM_BUFFER,
|
||||
XAUTOCLAIM_JUSTID,
|
||||
xAutoClaimJustId: XAUTOCLAIM_JUSTID,
|
||||
XAUTOCLAIM,
|
||||
xAutoClaim: XAUTOCLAIM,
|
||||
XCLAIM,
|
||||
xClaim: XCLAIM,
|
||||
XCLAIM_JUSTID_BUFFER,
|
||||
xClaimJustIdBuffer: XCLAIM_JUSTID_BUFFER,
|
||||
XCLAIM_BUFFER,
|
||||
xClaimBuffer: XCLAIM_BUFFER,
|
||||
XCLAIM_JUSTID,
|
||||
xClaimJustId: XCLAIM_JUSTID,
|
||||
XDEL,
|
||||
@@ -487,20 +447,12 @@ export default {
|
||||
xPendingRange: XPENDING_RANGE,
|
||||
XPENDING,
|
||||
xPending: XPENDING,
|
||||
XRANGE_BUFFER,
|
||||
xRangeBuffer: XRANGE_BUFFER,
|
||||
XRANGE,
|
||||
xRange: XRANGE,
|
||||
XREAD_BUFFER,
|
||||
xReadBuffer: XREAD_BUFFER,
|
||||
XREAD,
|
||||
xRead: XREAD,
|
||||
XREADGROUP_BUFFER,
|
||||
xReadGroupBuffer: XREADGROUP_BUFFER,
|
||||
XREADGROUP,
|
||||
xReadGroup: XREADGROUP,
|
||||
XREVRANGE_BUFFER,
|
||||
xRevRangeBuffer: XREVRANGE_BUFFER,
|
||||
XREVRANGE,
|
||||
xRevRange: XREVRANGE,
|
||||
XTRIM,
|
||||
|
@@ -76,8 +76,7 @@ export default class RedisCluster<M extends RedisModules = Record<string, never>
|
||||
RedisCluster.extractFirstKey(command, args, redisArgs),
|
||||
command.IS_READ_ONLY,
|
||||
redisArgs,
|
||||
options,
|
||||
command.BUFFER_MODE
|
||||
options
|
||||
),
|
||||
redisArgs.preserve
|
||||
);
|
||||
@@ -88,19 +87,18 @@ export default class RedisCluster<M extends RedisModules = Record<string, never>
|
||||
isReadonly: boolean | undefined,
|
||||
args: RedisCommandArguments,
|
||||
options?: ClientCommandOptions,
|
||||
bufferMode?: boolean,
|
||||
redirections = 0
|
||||
): Promise<RedisCommandReply<C>> {
|
||||
const client = this.#slots.getClient(firstKey, isReadonly);
|
||||
|
||||
try {
|
||||
return await client.sendCommand(args, options, bufferMode);
|
||||
return await client.sendCommand(args, options);
|
||||
} catch (err: any) {
|
||||
const shouldRetry = await this.#handleCommandError(err, client, redirections);
|
||||
if (shouldRetry === true) {
|
||||
return this.sendCommand(firstKey, isReadonly, args, options, bufferMode, redirections + 1);
|
||||
return this.sendCommand(firstKey, isReadonly, args, options, redirections + 1);
|
||||
} else if (shouldRetry) {
|
||||
return shouldRetry.sendCommand(args, options, bufferMode);
|
||||
return shouldRetry.sendCommand(args, options);
|
||||
}
|
||||
|
||||
throw err;
|
||||
@@ -135,13 +133,13 @@ export default class RedisCluster<M extends RedisModules = Record<string, never>
|
||||
);
|
||||
|
||||
try {
|
||||
return await client.executeScript(script, redisArgs, options, script.BUFFER_MODE);
|
||||
return await client.executeScript(script, redisArgs, options);
|
||||
} catch (err: any) {
|
||||
const shouldRetry = await this.#handleCommandError(err, client, redirections);
|
||||
if (shouldRetry === true) {
|
||||
return this.executeScript(script, originalArgs, redisArgs, options, redirections + 1);
|
||||
} else if (shouldRetry) {
|
||||
return shouldRetry.executeScript(script, redisArgs, options, script.BUFFER_MODE);
|
||||
return shouldRetry.executeScript(script, redisArgs, options);
|
||||
}
|
||||
|
||||
throw err;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(categoryName?: string): Array<string> {
|
||||
const args = ['ACL', 'CAT'];
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(categoryName?: RedisCommandArgument): RedisCommandArguments {
|
||||
const args: RedisCommandArguments = ['ACL', 'CAT'];
|
||||
|
||||
if (categoryName) {
|
||||
args.push(categoryName);
|
||||
@@ -8,4 +10,4 @@ export function transformArguments(categoryName?: string): Array<string> {
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(username: string | Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
username: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['ACL', 'DELUSER'], username);
|
||||
}
|
||||
|
||||
export declare const transformReply: (reply: number) => number;
|
||||
export declare function transformReply(): number;
|
||||
|
@@ -1,4 +1,6 @@
|
||||
export function transformArguments(bits?: number): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(bits?: number): RedisCommandArguments {
|
||||
const args = ['ACL', 'GENPASS'];
|
||||
|
||||
if (bits) {
|
||||
@@ -8,4 +10,4 @@ export function transformArguments(bits?: number): Array<string> {
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,26 +1,28 @@
|
||||
export function transformArguments(username: string): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(username: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['ACL', 'GETUSER', username];
|
||||
}
|
||||
|
||||
type AclGetUserRawReply = [
|
||||
_: string,
|
||||
flags: Array<string>,
|
||||
_: string,
|
||||
passwords: Array<string>,
|
||||
_: string,
|
||||
commands: string,
|
||||
_: string,
|
||||
keys: Array<string>,
|
||||
_: string,
|
||||
channels: Array<string>
|
||||
_: RedisCommandArgument,
|
||||
flags: Array<RedisCommandArgument>,
|
||||
_: RedisCommandArgument,
|
||||
passwords: Array<RedisCommandArgument>,
|
||||
_: RedisCommandArgument,
|
||||
commands: RedisCommandArgument,
|
||||
_: RedisCommandArgument,
|
||||
keys: Array<RedisCommandArgument>,
|
||||
_: RedisCommandArgument,
|
||||
channels: Array<RedisCommandArgument>
|
||||
];
|
||||
|
||||
interface AclUser {
|
||||
flags: Array<string>;
|
||||
passwords: Array<string>;
|
||||
commands: string;
|
||||
keys: Array<string>;
|
||||
channels: Array<string>
|
||||
flags: Array<RedisCommandArgument>;
|
||||
passwords: Array<RedisCommandArgument>;
|
||||
commands: RedisCommandArgument;
|
||||
keys: Array<RedisCommandArgument>;
|
||||
channels: Array<RedisCommandArgument>
|
||||
}
|
||||
|
||||
export function transformReply(reply: AclGetUserRawReply): AclUser {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ACL', 'LIST'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ACL', 'LOAD'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,4 +1,6 @@
|
||||
export function transformArguments(count?: number): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(count?: number): RedisCommandArguments {
|
||||
const args = ['ACL', 'LOG'];
|
||||
|
||||
if (count) {
|
||||
@@ -9,30 +11,30 @@ export function transformArguments(count?: number): Array<string> {
|
||||
}
|
||||
|
||||
type AclLogRawReply = [
|
||||
_: string,
|
||||
_: RedisCommandArgument,
|
||||
count: number,
|
||||
_: string,
|
||||
reason: string,
|
||||
_: string,
|
||||
context: string,
|
||||
_: string,
|
||||
object: string,
|
||||
_: string,
|
||||
username: string,
|
||||
_: string,
|
||||
ageSeconds: string,
|
||||
_: string,
|
||||
clientInfo: string
|
||||
_: RedisCommandArgument,
|
||||
reason: RedisCommandArgument,
|
||||
_: RedisCommandArgument,
|
||||
context: RedisCommandArgument,
|
||||
_: RedisCommandArgument,
|
||||
object: RedisCommandArgument,
|
||||
_: RedisCommandArgument,
|
||||
username: RedisCommandArgument,
|
||||
_: RedisCommandArgument,
|
||||
ageSeconds: RedisCommandArgument,
|
||||
_: RedisCommandArgument,
|
||||
clientInfo: RedisCommandArgument
|
||||
];
|
||||
|
||||
interface AclLog {
|
||||
count: number;
|
||||
reason: string;
|
||||
context: string;
|
||||
object: string;
|
||||
username: string;
|
||||
reason: RedisCommandArgument;
|
||||
context: RedisCommandArgument;
|
||||
object: RedisCommandArgument;
|
||||
username: RedisCommandArgument;
|
||||
ageSeconds: number;
|
||||
clientInfo: string;
|
||||
clientInfo: RedisCommandArgument;
|
||||
}
|
||||
|
||||
export function transformReply(reply: Array<AclLogRawReply>): Array<AclLog> {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ACL', 'LOG', 'RESET'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ACL', 'SAVE'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,8 +1,11 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(username: string, rule: string | Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
username: RedisCommandArgument,
|
||||
rule: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['ACL', 'SETUSER', username], rule);
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ACL', 'USERS'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ACL', 'WHOAMI'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArguments, RedisCommandArgument } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['ASKING'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export interface AuthOptions {
|
||||
username?: string;
|
||||
password: string;
|
||||
username?: RedisCommandArgument;
|
||||
password: RedisCommandArgument;
|
||||
}
|
||||
|
||||
export function transformArguments({username, password}: AuthOptions): Array<string> {
|
||||
export function transformArguments({ username, password }: AuthOptions): RedisCommandArguments {
|
||||
if (!username) {
|
||||
return ['AUTH', password];
|
||||
}
|
||||
@@ -11,4 +13,4 @@ export function transformArguments({username, password}: AuthOptions): Array<str
|
||||
return ['AUTH', username, password];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['BGREWRITEAOF'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
interface BgSaveOptions {
|
||||
SCHEDULE?: true;
|
||||
}
|
||||
|
||||
export function transformArguments(options?: BgSaveOptions): Array<string> {
|
||||
export function transformArguments(options?: BgSaveOptions): RedisCommandArguments {
|
||||
const args = ['BGSAVE'];
|
||||
|
||||
if (options?.SCHEDULE) {
|
||||
@@ -12,4 +14,4 @@ export function transformArguments(options?: BgSaveOptions): Array<string> {
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
@@ -7,7 +9,10 @@ interface BitCountRange {
|
||||
end: number;
|
||||
}
|
||||
|
||||
export function transformArguments(key: string, range?: BitCountRange): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
range?: BitCountRange
|
||||
): RedisCommandArguments {
|
||||
const args = ['BITCOUNT', key];
|
||||
|
||||
if (range) {
|
||||
|
@@ -1,11 +1,15 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } 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>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
operation: BitOperations,
|
||||
destKey: RedisCommandArgument,
|
||||
key: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['BITOP', operation, destKey], key);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,16 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { BitValue } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, bit: BitValue, start?: number, end?: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
bit: BitValue,
|
||||
start?: number,
|
||||
end?: number
|
||||
): RedisCommandArguments {
|
||||
const args = ['BITPOS', key, bit.toString()];
|
||||
|
||||
if (typeof start === 'number') {
|
||||
|
@@ -20,4 +20,4 @@ export function transformArguments(
|
||||
];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,5 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, transformArguments } from './BLMOVE';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export declare function transformReply(): Buffer | null;
|
@@ -14,12 +14,14 @@ export function transformArguments(
|
||||
return args;
|
||||
}
|
||||
|
||||
type BLPopRawReply = null | [RedisCommandArgument, RedisCommandArgument];
|
||||
|
||||
type BLPopReply = null | {
|
||||
key: string;
|
||||
element: string;
|
||||
key: RedisCommandArgument;
|
||||
element: RedisCommandArgument;
|
||||
};
|
||||
|
||||
export function transformReply(reply: null | [string, string]): BLPopReply {
|
||||
export function transformReply(reply: BLPopRawReply): BLPopReply {
|
||||
if (reply === null) return null;
|
||||
|
||||
return {
|
||||
|
@@ -1,17 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, transformArguments } from './BLPOP';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
type BLPopBufferReply = null | {
|
||||
key: Buffer;
|
||||
element: Buffer;
|
||||
};
|
||||
|
||||
export function transformReply(reply: null | [Buffer, Buffer]): BLPopBufferReply {
|
||||
if (reply === null) return null;
|
||||
|
||||
return {
|
||||
key: reply[0],
|
||||
element: reply[1]
|
||||
};
|
||||
}
|
@@ -1,9 +1,12 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||
timeout: number
|
||||
): RedisCommandArguments {
|
||||
const args = pushVerdictArguments(['BRPOP'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@@ -10,4 +10,4 @@ export function transformArguments(
|
||||
return ['BRPOPLPUSH', source, destination, timeout.toString()];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,5 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, transformArguments } from './BRPOPLPUSH';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export declare function transformReply(): Buffer | null;
|
@@ -1,3 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, transformArguments } from './BRPOP';
|
||||
|
||||
export { BUFFER_MODE, transformReply } from './BLPOP_BUFFER';
|
@@ -1,5 +1,5 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
|
||||
import { pushVerdictArguments, transformNumberInfinityReply, ZMember } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
@@ -14,18 +14,16 @@ export function transformArguments(
|
||||
return args;
|
||||
}
|
||||
|
||||
interface ZMemberWithKey extends ZMember<string> {
|
||||
key: string;
|
||||
}
|
||||
type ZMemberRawReply = [key: RedisCommandArgument, value: RedisCommandArgument, score: RedisCommandArgument] | null;
|
||||
|
||||
type BZPopMaxReply = ZMemberWithKey | null;
|
||||
type BZPopMaxReply = (ZMember & { key: RedisCommandArgument }) | null;
|
||||
|
||||
export function transformReply(reply: [key: string, value: string, score: string] | null): BZPopMaxReply | null {
|
||||
export function transformReply(reply: ZMemberRawReply): BZPopMaxReply | null {
|
||||
if (!reply) return null;
|
||||
|
||||
return {
|
||||
key: reply[0],
|
||||
value: reply[1],
|
||||
score: transformReplyNumberInfinity(reply[2])
|
||||
score: transformNumberInfinityReply(reply[2])
|
||||
};
|
||||
}
|
||||
|
@@ -1,9 +1,12 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||
timeout: number
|
||||
): RedisCommandArguments {
|
||||
const args = pushVerdictArguments(['BZPOPMIN'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
@@ -11,18 +14,4 @@ export function transformArguments(key: string | Array<string>, timeout: number)
|
||||
return args;
|
||||
}
|
||||
|
||||
interface ZMemberWithKey extends ZMember<string> {
|
||||
key: string;
|
||||
}
|
||||
|
||||
type BZPopMinReply = ZMemberWithKey | null;
|
||||
|
||||
export function transformReply(reply: [key: string, value: string, score: string] | null): BZPopMinReply | null {
|
||||
if (!reply) return null;
|
||||
|
||||
return {
|
||||
key: reply[0],
|
||||
value: reply[1],
|
||||
score: transformReplyNumberInfinity(reply[2])
|
||||
};
|
||||
}
|
||||
export { transformReply } from './BZPOPMAX';
|
||||
|
@@ -8,4 +8,4 @@ export function transformArguments(value: boolean): RedisCommandArguments {
|
||||
];
|
||||
}
|
||||
|
||||
export declare function transformReply(): 'OK';
|
||||
export declare function transformReply(): 'OK' | Buffer;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(name: string): RedisCommandArguments {
|
||||
export function transformArguments(name: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['CLIENT', 'SETNAME', name];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(args: Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(args: Array<RedisCommandArgument>): RedisCommandArguments {
|
||||
return ['COMMAND', 'GETKEYS', ...args];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -2,4 +2,4 @@ export function transformArguments(parameter: string): Array<string> {
|
||||
return ['CONFIG', 'GET', parameter];
|
||||
}
|
||||
|
||||
export { transformReplyStringTuples as transformReply } from './generic-transformers';
|
||||
export { transformTuplesReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
interface CopyCommandOptions {
|
||||
destinationDb?: number;
|
||||
replace?: boolean;
|
||||
@@ -5,7 +7,11 @@ interface CopyCommandOptions {
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(source: string, destination: string, options?: CopyCommandOptions): Array<string> {
|
||||
export function transformArguments(
|
||||
source: RedisCommandArgument,
|
||||
destination: RedisCommandArgument,
|
||||
options?: CopyCommandOptions
|
||||
): RedisCommandArguments {
|
||||
const args = ['COPY', source, destination];
|
||||
|
||||
if (options?.destinationDb) {
|
||||
@@ -19,4 +25,4 @@ export function transformArguments(source: string, destination: string, options?
|
||||
return args;
|
||||
}
|
||||
|
||||
export { transformReplyBoolean as transformReply } from './generic-transformers';
|
||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['DECR', key];
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,11 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, decrement: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
decrement: number
|
||||
): RedisCommandArguments {
|
||||
return ['DECRBY', key, decrement.toString()];
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
keys: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['DEL'], keys);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
import { RedisCommandArgument } from '.';
|
||||
|
||||
export function transformArguments(): Array<string> {
|
||||
return ['DISCARD'];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['DUMP', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(message: string): Array<string> {
|
||||
export function transformArguments(message: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['ECHO', message];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
keys: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['EXISTS'], keys);
|
||||
}
|
||||
|
||||
export { transformReplyBoolean as transformReply } from './generic-transformers';
|
||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,5 +1,12 @@
|
||||
export function transformArguments(key: string, seconds: number): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
seconds: number
|
||||
): RedisCommandArguments {
|
||||
return ['EXPIRE', key, seconds.toString()];
|
||||
}
|
||||
|
||||
export { transformReplyBoolean as transformReply } from './generic-transformers';
|
||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,6 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { transformEXAT } from './generic-transformers';
|
||||
|
||||
export function transformArguments(key: string, timestamp: number | Date): Array<string> {
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
timestamp: number | Date
|
||||
): RedisCommandArguments {
|
||||
return [
|
||||
'EXPIREAT',
|
||||
key,
|
||||
@@ -8,4 +14,4 @@ export function transformArguments(key: string, timestamp: number | Date): Array
|
||||
];
|
||||
}
|
||||
|
||||
export { transformReplyBoolean as transformReply } from './generic-transformers';
|
||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { GeoCoordinates } from './generic-transformers';
|
||||
|
||||
interface GeoMember extends GeoCoordinates {
|
||||
member: string;
|
||||
member: RedisCommandArgument;
|
||||
}
|
||||
|
||||
interface NX {
|
||||
@@ -22,7 +23,10 @@ type GeoAddOptions = SetGuards & GeoAddCommonOptions;
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, toAdd: GeoMember | Array<GeoMember>, options?: GeoAddOptions): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument, toAdd: GeoMember | Array<GeoMember>,
|
||||
options?: GeoAddOptions
|
||||
): RedisCommandArguments {
|
||||
const args = ['GEOADD', key];
|
||||
|
||||
if ((options as NX)?.NX) {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { GeoUnits } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@@ -5,11 +6,11 @@ export const FIRST_KEY_INDEX = 1;
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
member1: string,
|
||||
member2: string,
|
||||
key: RedisCommandArgument,
|
||||
member1: RedisCommandArgument,
|
||||
member2: RedisCommandArgument,
|
||||
unit?: GeoUnits
|
||||
): Array<string> {
|
||||
): RedisCommandArguments {
|
||||
const args = ['GEODIST', key, member1, member2];
|
||||
|
||||
if (unit) {
|
||||
@@ -19,6 +20,6 @@ export function transformArguments(
|
||||
return args;
|
||||
}
|
||||
|
||||
export function transformReply(reply: string | null): number | null {
|
||||
export function transformReply(reply: RedisCommandArgument | null): number | null {
|
||||
return reply === null ? null : Number(reply);
|
||||
}
|
||||
|
@@ -1,12 +1,15 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } 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>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
member: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['GEOHASH', key], member);
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,20 +1,25 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } 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>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
member: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['GEOPOS', key], member);
|
||||
}
|
||||
|
||||
type GeoCoordinatesRawReply = Array<[RedisCommandArgument, RedisCommandArgument] | null>;
|
||||
|
||||
interface GeoCoordinates {
|
||||
longitude: string;
|
||||
latitude: string;
|
||||
longitude: RedisCommandArgument;
|
||||
latitude: RedisCommandArgument;
|
||||
}
|
||||
|
||||
export function transformReply(reply: Array<[string, string] | null>): Array<GeoCoordinates | null> {
|
||||
export function transformReply(reply: GeoCoordinatesRawReply): Array<GeoCoordinates | null> {
|
||||
return reply.map(coordinates => coordinates === null ? null : {
|
||||
longitude: coordinates[0],
|
||||
latitude: coordinates[1]
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@@ -5,12 +6,12 @@ export const FIRST_KEY_INDEX = 1;
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
key: RedisCommandArgument,
|
||||
from: GeoSearchFrom,
|
||||
by: GeoSearchBy,
|
||||
options?: GeoSearchOptions
|
||||
): Array<string> {
|
||||
): RedisCommandArguments {
|
||||
return pushGeoSearchArguments(['GEOSEARCH'], key, from, by, options);
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@@ -9,12 +10,12 @@ interface GeoSearchStoreOptions extends GeoSearchOptions {
|
||||
}
|
||||
|
||||
export function transformArguments(
|
||||
destination: string,
|
||||
source: string,
|
||||
destination: RedisCommandArgument,
|
||||
source: RedisCommandArgument,
|
||||
from: GeoSearchFrom,
|
||||
by: GeoSearchBy,
|
||||
options?: GeoSearchStoreOptions
|
||||
): Array<string> {
|
||||
): RedisCommandArguments {
|
||||
const args = pushGeoSearchArguments(
|
||||
['GEOSEARCHSTORE', destination],
|
||||
source,
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { GeoSearchFrom, GeoSearchBy, GeoReplyWith, GeoSearchOptions } from './generic-transformers';
|
||||
import { transformArguments as geoSearchTransformArguments } from './GEOSEARCH';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEOSEARCH';
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
key: RedisCommandArgument,
|
||||
from: GeoSearchFrom,
|
||||
by: GeoSearchBy,
|
||||
replyWith: Array<GeoReplyWith>,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import RedisClient from '../client';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GET';
|
||||
|
||||
@@ -11,6 +12,12 @@ describe('GET', () => {
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.get', async client => {
|
||||
const a = await client.get(
|
||||
'key'
|
||||
);
|
||||
|
||||
|
||||
|
||||
assert.equal(
|
||||
await client.get('key'),
|
||||
null
|
||||
|
@@ -8,4 +8,4 @@ export function transformArguments(key: RedisCommandArgument): RedisCommandArgum
|
||||
return ['GET', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,10 +1,14 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { BitValue } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, offset: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
offset: number
|
||||
): RedisCommandArguments {
|
||||
return ['GETBIT', key, offset.toString()];
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['GETDEL', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { transformEXAT, transformPXAT } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@@ -15,7 +15,10 @@ type GetExModes = {
|
||||
PERSIST: true;
|
||||
};
|
||||
|
||||
export function transformArguments(key: string, mode: GetExModes): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
mode: GetExModes
|
||||
): RedisCommandArguments {
|
||||
const args = ['GETEX', key];
|
||||
|
||||
if ('EX' in mode) {
|
||||
@@ -33,4 +36,4 @@ export function transformArguments(key: string, mode: GetExModes): RedisCommandA
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,9 +1,15 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, start: number, end: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
start: number,
|
||||
end: number
|
||||
): RedisCommandArguments {
|
||||
return ['GETRANGE', key, start.toString(), end.toString()];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, value: string): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
value: RedisCommandArgument
|
||||
): RedisCommandArguments {
|
||||
return ['GETSET', key, value];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,22 +0,0 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
|
||||
describe('GET_BUFFER', () => {
|
||||
testUtils.testWithClient('client.getBuffer', async client => {
|
||||
const buffer = Buffer.from('string');
|
||||
await client.set('key', buffer);
|
||||
assert.deepEqual(
|
||||
buffer,
|
||||
await client.getBuffer('key')
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.getBuffer', async cluster => {
|
||||
const buffer = Buffer.from('string');
|
||||
await cluster.set('key', buffer);
|
||||
assert.deepEqual(
|
||||
buffer,
|
||||
await cluster.getBuffer('key')
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
@@ -1,5 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY, transformArguments } from './GET';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export declare function transformReply(): Buffer | null;
|
@@ -1,9 +1,12 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string | Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
field: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['HDEL', key], field);
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { AuthOptions } from './AUTH';
|
||||
|
||||
interface HelloOptions {
|
||||
@@ -6,8 +7,8 @@ interface HelloOptions {
|
||||
clientName?: string;
|
||||
}
|
||||
|
||||
export function transformArguments(options?: HelloOptions): Array<string> {
|
||||
const args = ['HELLO'];
|
||||
export function transformArguments(options?: HelloOptions): RedisCommandArguments {
|
||||
const args: RedisCommandArguments = ['HELLO'];
|
||||
|
||||
if (options) {
|
||||
args.push(options.protover.toString());
|
||||
@@ -26,29 +27,29 @@ export function transformArguments(options?: HelloOptions): Array<string> {
|
||||
|
||||
type HelloRawReply = [
|
||||
_: never,
|
||||
server: string,
|
||||
server: RedisCommandArgument,
|
||||
_: never,
|
||||
version: string,
|
||||
version: RedisCommandArgument,
|
||||
_: never,
|
||||
proto: number,
|
||||
_: never,
|
||||
id: number,
|
||||
_: never,
|
||||
mode: string,
|
||||
mode: RedisCommandArgument,
|
||||
_: never,
|
||||
role: string,
|
||||
role: RedisCommandArgument,
|
||||
_: never,
|
||||
modules: Array<string>
|
||||
modules: Array<RedisCommandArgument>
|
||||
];
|
||||
|
||||
interface HelloTransformedReply {
|
||||
server: string;
|
||||
version: string;
|
||||
server: RedisCommandArgument;
|
||||
version: RedisCommandArgument;
|
||||
proto: number;
|
||||
id: number;
|
||||
mode: string;
|
||||
role: string;
|
||||
modules: Array<string>;
|
||||
mode: RedisCommandArgument;
|
||||
role: RedisCommandArgument;
|
||||
modules: Array<RedisCommandArgument>;
|
||||
}
|
||||
|
||||
export function transformReply(reply: HelloRawReply): HelloTransformedReply {
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
field: RedisCommandArgument
|
||||
): RedisCommandArguments {
|
||||
return ['HEXISTS', key, field];
|
||||
}
|
||||
|
||||
export { transformReplyBoolean as transformReply } from './generic-transformers';
|
||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||
|
@@ -11,4 +11,4 @@ export function transformArguments(
|
||||
return ['HGET', key, field];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | undefined;
|
||||
export declare function transformReply(): RedisCommandArgument | undefined;
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['HGETALL', key];
|
||||
}
|
||||
|
||||
export { transformReplyStringTuples as transformReply } from './generic-transformers';
|
||||
export { transformTuplesReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,5 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY, transformArguments } from './HGETALL';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export { transformReplyBufferTuples as transformReply } from './generic-transformers';
|
@@ -1,5 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY, transformArguments } from './HGET';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export declare function transformReply(): Buffer | undefined;
|
@@ -1,6 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string, increment: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
field: RedisCommandArgument,
|
||||
increment: number
|
||||
): RedisCommandArguments {
|
||||
return ['HINCRBY', key, field, increment.toString()];
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string, increment: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
field: RedisCommandArgument,
|
||||
increment: number
|
||||
): RedisCommandArguments {
|
||||
return ['HINCRBYFLOAT', key, field, increment.toString()];
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['HKEYS', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['HLEN', key];
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,15 @@
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, fields: string | Array<string>): RedisCommandArguments {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
fields: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
): RedisCommandArguments {
|
||||
return pushVerdictArguments(['HMGET', key], fields);
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['HRANDFIELD', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,12 +1,16 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { transformArguments as transformHRandFieldArguments } from './HRANDFIELD';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './HRANDFIELD';
|
||||
|
||||
export function transformArguments(key: string, count: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
count: number
|
||||
): RedisCommandArguments {
|
||||
return [
|
||||
...transformHRandFieldArguments(key),
|
||||
count.toString()
|
||||
];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,12 +1,16 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { transformArguments as transformHRandFieldCountArguments } from './HRANDFIELD_COUNT';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './HRANDFIELD_COUNT';
|
||||
|
||||
export function transformArguments(key: string, count: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
count: number
|
||||
): RedisCommandArguments {
|
||||
return [
|
||||
...transformHRandFieldCountArguments(key, count),
|
||||
'WITHVALUES'
|
||||
];
|
||||
}
|
||||
|
||||
export { transformReplyStringTuples as transformReply } from './generic-transformers';
|
||||
export { transformTuplesReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,5 +0,0 @@
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY, transformArguments } from './HRANDFIELD_COUNT';
|
||||
|
||||
export const BUFFER_MODE = true;
|
||||
|
||||
export { transformReplyBufferTuples as transformReply } from './generic-transformers';
|
@@ -1,19 +1,26 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { ScanOptions, pushScanArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, cursor: number, options?: ScanOptions): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
cursor: number,
|
||||
options?: ScanOptions
|
||||
): RedisCommandArguments {
|
||||
return pushScanArguments([
|
||||
'HSCAN',
|
||||
key
|
||||
], cursor, options);
|
||||
}
|
||||
|
||||
type HScanRawReply = [RedisCommandArgument, Array<RedisCommandArgument>];
|
||||
|
||||
export interface HScanTuple {
|
||||
field: string;
|
||||
value: string;
|
||||
field: RedisCommandArgument;
|
||||
value: RedisCommandArgument;
|
||||
}
|
||||
|
||||
interface HScanReply {
|
||||
@@ -21,7 +28,7 @@ interface HScanReply {
|
||||
tuples: Array<HScanTuple>;
|
||||
}
|
||||
|
||||
export function transformReply([cursor, rawTuples]: [string, Array<string>]): HScanReply {
|
||||
export function transformReply([cursor, rawTuples]: HScanRawReply): HScanReply {
|
||||
const parsedTuples = [];
|
||||
for (let i = 0; i < rawTuples.length; i += 2) {
|
||||
parsedTuples.push({
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
type Types = string | number | Buffer;
|
||||
type Types = RedisCommandArgument | number;
|
||||
|
||||
type HSETObject = Record<string | number, Types>;
|
||||
|
||||
|
@@ -1,7 +1,13 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string, value: string): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
field: RedisCommandArgument,
|
||||
value: RedisCommandArgument
|
||||
): RedisCommandArguments {
|
||||
return ['HSETNX', key, field, value];
|
||||
}
|
||||
|
||||
export { transformReplyBoolean as transformReply } from './generic-transformers';
|
||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||
|
@@ -1,6 +1,11 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
field: RedisCommandArgument
|
||||
): RedisCommandArguments {
|
||||
return ['HSTRLEN', key, field];
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['HVALS', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string>;
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['INCR', key];
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,11 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, increment: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
increment: number
|
||||
): RedisCommandArguments {
|
||||
return ['INCRBY', key, increment.toString()];
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, increment: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
increment: number
|
||||
): RedisCommandArguments {
|
||||
return ['INCRBYFLOAT', key, increment.toString()];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
export function transformArguments(pattern: string): Array<string> {
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(pattern: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['KEYS', pattern];
|
||||
}
|
||||
|
||||
export function transformReply(keys: Array<string>): Array<string> {
|
||||
return keys;
|
||||
}
|
||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
|
@@ -1,8 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, index: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
index: number
|
||||
): RedisCommandArguments {
|
||||
return ['LINDEX', key, index.toString()];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,13 +1,15 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
type LInsertPosition = 'BEFORE' | 'AFTER';
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
key: RedisCommandArgument,
|
||||
position: LInsertPosition,
|
||||
pivot: string,
|
||||
element: string
|
||||
): Array<string> {
|
||||
pivot: RedisCommandArgument,
|
||||
element: RedisCommandArgument
|
||||
): RedisCommandArguments {
|
||||
return [
|
||||
'LINSERT',
|
||||
key,
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['LLEN', key];
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,15 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export type LMoveSide = 'LEFT' | 'RIGHT';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(
|
||||
source: string,
|
||||
destination: string,
|
||||
source: RedisCommandArgument,
|
||||
destination: RedisCommandArgument,
|
||||
sourceSide: LMoveSide,
|
||||
destinationSide: LMoveSide
|
||||
): Array<string> {
|
||||
): RedisCommandArguments {
|
||||
return [
|
||||
'LMOVE',
|
||||
source,
|
||||
@@ -17,4 +19,4 @@ export function transformArguments(
|
||||
];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import { RedisCommandArgument } from '.';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(version?: number, ...optionalArguments: Array<number>): Array<string> {
|
||||
@@ -14,4 +16,4 @@ export function transformArguments(version?: number, ...optionalArguments: Array
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export declare function transformReply(): RedisCommandArgument;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
||||
return ['LPOP', key];
|
||||
}
|
||||
|
||||
export declare function transformReply(): string | null;
|
||||
export declare function transformReply(): RedisCommandArgument | null;
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, count: number): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
count: number
|
||||
): RedisCommandArguments {
|
||||
return ['LPOP', key, count.toString()];
|
||||
}
|
||||
|
||||
export declare function transformReply(): Array<string> | null;
|
||||
export declare function transformReply(): Array<RedisCommandArgument> | null;
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
@@ -7,7 +9,11 @@ export interface LPosOptions {
|
||||
MAXLEN?: number;
|
||||
}
|
||||
|
||||
export function transformArguments(key: string, element: string, options?: LPosOptions): Array<string> {
|
||||
export function transformArguments(
|
||||
key: RedisCommandArgument,
|
||||
element: RedisCommandArgument,
|
||||
options?: LPosOptions
|
||||
): RedisCommandArguments {
|
||||
const args = ['LPOS', key, element];
|
||||
|
||||
if (typeof options?.RANK === 'number') {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user