You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
WIP
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
`String` -> `Double`:
|
`String` -> `Double`:
|
||||||
- `INCRBYFLOAT`
|
- `INCRBYFLOAT`
|
||||||
- `HINCRBYFLOAT`
|
- `HINCRBYFLOAT`
|
||||||
|
- `GEODIST`
|
||||||
|
|
||||||
`Number` -> `Boolean`:
|
`Number` -> `Boolean`:
|
||||||
- `HSETNX` (deprecated)
|
- `HSETNX` (deprecated)
|
||||||
|
@@ -45,6 +45,20 @@ Rather than using `client.quit()`, your code should use `client.close()` or `cli
|
|||||||
|
|
||||||
TODO difference between `close` and `disconnect`...
|
TODO difference between `close` and `disconnect`...
|
||||||
|
|
||||||
|
## Scan Iterators
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
Yields chunks instead of individual items:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
for await (const chunk of client.scanIterator()) {
|
||||||
|
// `chunk` type is `Array<string>`
|
||||||
|
// will allow multi keys operations
|
||||||
|
await client.del(chunk);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Some command arguments/replies have changed to align more closely to data types returned by Redis:
|
Some command arguments/replies have changed to align more closely to data types returned by Redis:
|
||||||
@@ -69,6 +83,8 @@ Some command arguments/replies have changed to align more closely to data types
|
|||||||
- `HSCAN`: `tuples` has been renamed to `entries`
|
- `HSCAN`: `tuples` has been renamed to `entries`
|
||||||
- `PFADD`: `boolean` -> `number` [^boolean-to-number]
|
- `PFADD`: `boolean` -> `number` [^boolean-to-number]
|
||||||
- `SCRIPT EXISTS`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
|
- `SCRIPT EXISTS`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
|
||||||
|
- `SISMEMBER`: `boolean` -> `number` [^boolean-to-number]
|
||||||
|
- `SMISMEMBER`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
|
||||||
|
|
||||||
[^enum-to-constants]: TODO
|
[^enum-to-constants]: TODO
|
||||||
|
|
||||||
|
@@ -12,13 +12,8 @@ import RedisClientMultiCommand, { RedisClientMultiCommandType } from './multi-co
|
|||||||
import { RedisMultiQueuedCommand } from '../multi-command';
|
import { RedisMultiQueuedCommand } from '../multi-command';
|
||||||
import HELLO, { HelloOptions } from '../commands/HELLO';
|
import HELLO, { HelloOptions } from '../commands/HELLO';
|
||||||
import { Pool, Options as PoolOptions, createPool } from 'generic-pool';
|
import { Pool, Options as PoolOptions, createPool } from 'generic-pool';
|
||||||
import { ReplyWithFlags, BlobStringReply } from '../RESP/types';
|
import { ReplyWithFlags, CommandReply } from '../RESP/types';
|
||||||
import { ScanCommandOptions } from '../commands/SCAN';
|
import SCAN, { ScanOptions, ScanCommonOptions } from '../commands/SCAN';
|
||||||
import { HScanEntry } from '../commands/HSCAN';
|
|
||||||
import { ScanOptions, ZMember } from '../commands/generic-transformers';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface RedisClientOptions<
|
export interface RedisClientOptions<
|
||||||
M extends RedisModules = RedisModules,
|
M extends RedisModules = RedisModules,
|
||||||
@@ -538,7 +533,7 @@ export default class RedisClient<
|
|||||||
value: V
|
value: V
|
||||||
) {
|
) {
|
||||||
const proxy = Object.create(this.self);
|
const proxy = Object.create(this.self);
|
||||||
proxy.commandOptions = Object.create((this as ProxyClient).commandOptions ?? null);
|
proxy.commandOptions = Object.create((this as unknown as ProxyClient).commandOptions ?? null);
|
||||||
proxy.commandOptions[key] = value;
|
proxy.commandOptions[key] = value;
|
||||||
return proxy as RedisClientType<
|
return proxy as RedisClientType<
|
||||||
M,
|
M,
|
||||||
@@ -840,60 +835,52 @@ export default class RedisClient<
|
|||||||
|
|
||||||
async* scanIterator(
|
async* scanIterator(
|
||||||
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
||||||
options?: ScanCommandOptions & ScanIteratorOptions
|
options?: ScanOptions & ScanIteratorOptions
|
||||||
): AsyncIterable<ReplyWithFlags<BlobStringReply, FLAGS>> {
|
): AsyncIterable<ReplyWithFlags<CommandReply<typeof SCAN, RESP>['keys'], FLAGS>> {
|
||||||
let cursor = options?.cursor ?? 0;
|
let cursor = options?.cursor ?? 0;
|
||||||
do {
|
do {
|
||||||
const reply = await this.scan(cursor, options);
|
const reply = await this.scan(cursor, options);
|
||||||
cursor = reply.cursor;
|
cursor = reply.cursor;
|
||||||
for (const key of reply.keys) {
|
yield reply.keys;
|
||||||
yield key;
|
|
||||||
}
|
|
||||||
} while (cursor !== 0);
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async* hScanIterator(
|
async* hScanIterator(
|
||||||
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
options?: ScanOptions & ScanIteratorOptions
|
options?: ScanCommonOptions & ScanIteratorOptions
|
||||||
): AsyncIterable<ReplyWithFlags<HScanEntry, FLAGS>> {
|
) {
|
||||||
let cursor = options?.cursor ?? 0;
|
let cursor = options?.cursor ?? 0;
|
||||||
do {
|
do {
|
||||||
const reply = await this.hScan(key, cursor, options);
|
const reply = await this.hScan(key, cursor, options);
|
||||||
cursor = reply.cursor;
|
cursor = reply.cursor;
|
||||||
for (const entry of reply.entries) {
|
yield reply.entries;
|
||||||
yield entry;
|
|
||||||
}
|
|
||||||
} while (cursor !== 0);
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async* sScanIterator(
|
async* sScanIterator(
|
||||||
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
options?: ScanOptions & ScanIteratorOptions
|
options?: ScanCommonOptions & ScanIteratorOptions
|
||||||
): AsyncIterable<ReplyWithFlags<BlobStringReply, FLAGS>> {
|
) {
|
||||||
let cursor = options?.cursor ?? 0;
|
let cursor = options?.cursor ?? 0;
|
||||||
do {
|
do {
|
||||||
const reply = await this.sScan(key, cursor, options);
|
const reply = await this.sScan(key, cursor, options);
|
||||||
cursor = reply.cursor;
|
cursor = reply.cursor;
|
||||||
for (const member of reply.members) {
|
yield reply.members;
|
||||||
yield member;
|
|
||||||
}
|
|
||||||
} while (cursor !== 0);
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async* zScanIterator(
|
async* zScanIterator(
|
||||||
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
this: RedisClientType<M, F, S, RESP, FLAGS>,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
options?: ScanOptions & ScanIteratorOptions
|
options?: ScanCommonOptions & ScanIteratorOptions
|
||||||
): AsyncIterable<ReplyWithFlags<ZMember, FLAGS>> {
|
) {
|
||||||
let cursor = options?.cursor ?? 0;
|
let cursor = options?.cursor ?? 0;
|
||||||
do {
|
do {
|
||||||
const reply = await this.zScan(key, cursor, options);
|
const reply = await this.zScan(key, cursor, options);
|
||||||
cursor = reply.cursor;
|
cursor = reply.cursor;
|
||||||
for (const member of reply.members) {
|
yield reply.members;
|
||||||
yield member;
|
|
||||||
}
|
|
||||||
} while (cursor !== 0);
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -326,7 +326,7 @@ export default class RedisCluster<
|
|||||||
value: V
|
value: V
|
||||||
) {
|
) {
|
||||||
const proxy = Object.create(this);
|
const proxy = Object.create(this);
|
||||||
proxy.commandOptions = Object.create((this as ProxyCluster).commandOptions ?? null);
|
proxy.commandOptions = Object.create((this as unknown as ProxyCluster).commandOptions ?? null);
|
||||||
proxy.commandOptions[key] = value;
|
proxy.commandOptions[key] = value;
|
||||||
return proxy as RedisClusterType<
|
return proxy as RedisClusterType<
|
||||||
M,
|
M,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { RedisArgument, Command } from '../RESP/types';
|
import { Command } from '../RESP/types';
|
||||||
import { transformLMPopArguments, LMPopOptions, ListSide } from './generic-transformers';
|
import { transformLMPopArguments, LMPopOptions, ListSide, RedisVariadicArgument } from './generic-transformers';
|
||||||
import LMPOP from './LMPOP';
|
import LMPOP from './LMPOP';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -7,7 +7,7 @@ export default {
|
|||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
timeout: number,
|
timeout: number,
|
||||||
keys: RedisArgument | Array<RedisArgument>,
|
keys: RedisVariadicArgument,
|
||||||
side: ListSide,
|
side: ListSide,
|
||||||
options?: LMPopOptions
|
options?: LMPopOptions
|
||||||
) {
|
) {
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
import { BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
key: RedisArgument | Array<RedisArgument>,
|
key: RedisVariadicArgument,
|
||||||
timeout: number
|
timeout: number
|
||||||
) {
|
) {
|
||||||
const args = pushVariadicArguments(['BRPOP'], key);
|
const args = pushVariadicArguments(['BRPOP'], key);
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
import { Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
import BLPOP from './BLPOP';
|
import BLPOP from './BLPOP';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
key: RedisArgument | Array<RedisArgument>,
|
key: RedisVariadicArgument,
|
||||||
timeout: number
|
timeout: number
|
||||||
) {
|
) {
|
||||||
const args = pushVariadicArguments(['BRPOP'], key);
|
const args = pushVariadicArguments(['BRPOP'], key);
|
||||||
|
@@ -1,34 +1,34 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { SortedSetSide, transformZMPopArguments, ZMPopOptions } from './generic-transformers';
|
// import { SortedSetSide, transformZMPopArguments, ZMPopOptions } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 3;
|
// export const FIRST_KEY_INDEX = 3;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
timeout: number,
|
// timeout: number,
|
||||||
keys: RedisCommandArgument | Array<RedisCommandArgument>,
|
// keys: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||||
side: SortedSetSide,
|
// side: SortedSetSide,
|
||||||
options?: ZMPopOptions
|
// options?: ZMPopOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return transformZMPopArguments(
|
// return transformZMPopArguments(
|
||||||
['BZMPOP', timeout.toString()],
|
// ['BZMPOP', timeout.toString()],
|
||||||
keys,
|
// keys,
|
||||||
side,
|
// side,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformReply } from './ZMPOP';
|
// export { transformReply } from './ZMPOP';
|
||||||
|
|
||||||
|
|
||||||
import { Command } from '../RESP/types';
|
// import { Command } from '../RESP/types';
|
||||||
import ZMPOP from './ZMPOP';
|
// import ZMPOP from './ZMPOP';
|
||||||
|
|
||||||
export default {
|
// export default {
|
||||||
IS_READ_ONLY: false,
|
// FIRST_KEY_INDEX: 3,
|
||||||
FIRST_KEY_INDEX: 3,
|
// IS_READ_ONLY: false,
|
||||||
transformArguments() {
|
// transformArguments() {
|
||||||
return ['BZMPOP'];
|
// return ['BZMPOP'];
|
||||||
},
|
// },
|
||||||
transformReply: ZMPOP.transformReply
|
// transformReply: ZMPOP.transformReply
|
||||||
} as const satisfies Command;
|
// } as const satisfies Command;
|
||||||
|
|
||||||
|
@@ -1,29 +1,29 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { pushVariadicArguments, transformNumberInfinityReply, ZMember } from './generic-transformers';
|
// import { pushVariadicArguments, transformDoubleReply, ZMember } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument | Array<RedisCommandArgument>,
|
// key: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||||
timeout: number
|
// timeout: number
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = pushVariadicArguments(['BZPOPMAX'], key);
|
// const args = pushVariadicArguments(['BZPOPMAX'], key);
|
||||||
|
|
||||||
args.push(timeout.toString());
|
// args.push(timeout.toString());
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
type ZMemberRawReply = [key: RedisCommandArgument, value: RedisCommandArgument, score: RedisCommandArgument] | null;
|
// type ZMemberRawReply = [key: RedisCommandArgument, value: RedisCommandArgument, score: RedisCommandArgument] | null;
|
||||||
|
|
||||||
type BZPopMaxReply = (ZMember & { key: RedisCommandArgument }) | null;
|
// type BZPopMaxReply = (ZMember & { key: RedisCommandArgument }) | null;
|
||||||
|
|
||||||
export function transformReply(reply: ZMemberRawReply): BZPopMaxReply | null {
|
// export function transformReply(reply: ZMemberRawReply): BZPopMaxReply | null {
|
||||||
if (!reply) return null;
|
// if (!reply) return null;
|
||||||
|
|
||||||
return {
|
// return {
|
||||||
key: reply[0],
|
// key: reply[0],
|
||||||
value: reply[1],
|
// value: reply[1],
|
||||||
score: transformNumberInfinityReply(reply[2])
|
// score: transformDoubleReply(reply[2])
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
// import { pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument | Array<RedisCommandArgument>,
|
// key: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||||
timeout: number
|
// timeout: number
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = pushVariadicArguments(['BZPOPMIN'], key);
|
// const args = pushVariadicArguments(['BZPOPMIN'], key);
|
||||||
|
|
||||||
args.push(timeout.toString());
|
// args.push(timeout.toString());
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformReply } from './BZPOPMAX';
|
// export { transformReply } from './BZPOPMAX';
|
||||||
|
@@ -1,83 +1,83 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
interface CommonOptions {
|
// interface CommonOptions {
|
||||||
REDIRECT?: number;
|
// REDIRECT?: number;
|
||||||
NOLOOP?: boolean;
|
// NOLOOP?: boolean;
|
||||||
}
|
// }
|
||||||
|
|
||||||
interface BroadcastOptions {
|
// interface BroadcastOptions {
|
||||||
BCAST?: boolean;
|
// BCAST?: boolean;
|
||||||
PREFIX?: RedisCommandArgument | Array<RedisCommandArgument>;
|
// PREFIX?: RedisCommandArgument | Array<RedisCommandArgument>;
|
||||||
}
|
// }
|
||||||
|
|
||||||
interface OptInOptions {
|
// interface OptInOptions {
|
||||||
OPTIN?: boolean;
|
// OPTIN?: boolean;
|
||||||
}
|
// }
|
||||||
|
|
||||||
interface OptOutOptions {
|
// interface OptOutOptions {
|
||||||
OPTOUT?: boolean;
|
// OPTOUT?: boolean;
|
||||||
}
|
// }
|
||||||
|
|
||||||
type ClientTrackingOptions = CommonOptions & (
|
// type ClientTrackingOptions = CommonOptions & (
|
||||||
BroadcastOptions |
|
// BroadcastOptions |
|
||||||
OptInOptions |
|
// OptInOptions |
|
||||||
OptOutOptions
|
// OptOutOptions
|
||||||
);
|
// );
|
||||||
|
|
||||||
export function transformArguments<M extends boolean>(
|
// export function transformArguments<M extends boolean>(
|
||||||
mode: M,
|
// mode: M,
|
||||||
options?: M extends true ? ClientTrackingOptions : undefined
|
// options?: M extends true ? ClientTrackingOptions : undefined
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = [
|
// const args: RedisCommandArguments = [
|
||||||
'CLIENT',
|
// 'CLIENT',
|
||||||
'TRACKING',
|
// 'TRACKING',
|
||||||
mode ? 'ON' : 'OFF'
|
// mode ? 'ON' : 'OFF'
|
||||||
];
|
// ];
|
||||||
|
|
||||||
if (mode) {
|
// if (mode) {
|
||||||
if (options?.REDIRECT) {
|
// if (options?.REDIRECT) {
|
||||||
args.push(
|
// args.push(
|
||||||
'REDIRECT',
|
// 'REDIRECT',
|
||||||
options.REDIRECT.toString()
|
// options.REDIRECT.toString()
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (isBroadcast(options)) {
|
// if (isBroadcast(options)) {
|
||||||
args.push('BCAST');
|
// args.push('BCAST');
|
||||||
|
|
||||||
if (options?.PREFIX) {
|
// if (options?.PREFIX) {
|
||||||
if (Array.isArray(options.PREFIX)) {
|
// if (Array.isArray(options.PREFIX)) {
|
||||||
for (const prefix of options.PREFIX) {
|
// for (const prefix of options.PREFIX) {
|
||||||
args.push('PREFIX', prefix);
|
// args.push('PREFIX', prefix);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
args.push('PREFIX', options.PREFIX);
|
// args.push('PREFIX', options.PREFIX);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else if (isOptIn(options)) {
|
// } else if (isOptIn(options)) {
|
||||||
args.push('OPTIN');
|
// args.push('OPTIN');
|
||||||
} else if (isOptOut(options)) {
|
// } else if (isOptOut(options)) {
|
||||||
args.push('OPTOUT');
|
// args.push('OPTOUT');
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (options?.NOLOOP) {
|
// if (options?.NOLOOP) {
|
||||||
args.push('NOLOOP');
|
// args.push('NOLOOP');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function isBroadcast(options?: ClientTrackingOptions): options is BroadcastOptions {
|
// function isBroadcast(options?: ClientTrackingOptions): options is BroadcastOptions {
|
||||||
return (options as BroadcastOptions)?.BCAST === true;
|
// return (options as BroadcastOptions)?.BCAST === true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function isOptIn(options?: ClientTrackingOptions): options is OptInOptions {
|
// function isOptIn(options?: ClientTrackingOptions): options is OptInOptions {
|
||||||
return (options as OptInOptions)?.OPTIN === true;
|
// return (options as OptInOptions)?.OPTIN === true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function isOptOut(options?: ClientTrackingOptions): options is OptOutOptions {
|
// function isOptOut(options?: ClientTrackingOptions): options is OptOutOptions {
|
||||||
return (options as OptOutOptions)?.OPTOUT === true;
|
// return (options as OptOutOptions)?.OPTOUT === true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): 'OK' | Buffer;
|
// export declare function transformReply(): 'OK' | Buffer;
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export function transformArguments(): RedisCommandArguments {
|
// export function transformArguments(): RedisCommandArguments {
|
||||||
return ['CLIENT', 'TRACKINGINFO'];
|
// return ['CLIENT', 'TRACKINGINFO'];
|
||||||
}
|
// }
|
||||||
|
|
||||||
type RawReply = [
|
// type RawReply = [
|
||||||
'flags',
|
// 'flags',
|
||||||
Array<string>,
|
// Array<string>,
|
||||||
'redirect',
|
// 'redirect',
|
||||||
number,
|
// number,
|
||||||
'prefixes',
|
// 'prefixes',
|
||||||
Array<string>
|
// Array<string>
|
||||||
];
|
// ];
|
||||||
|
|
||||||
interface Reply {
|
// interface Reply {
|
||||||
flags: Set<string>;
|
// flags: Set<string>;
|
||||||
redirect: number;
|
// redirect: number;
|
||||||
prefixes: Array<string>;
|
// prefixes: Array<string>;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: RawReply): Reply {
|
// export function transformReply(reply: RawReply): Reply {
|
||||||
return {
|
// return {
|
||||||
flags: new Set(reply[1]),
|
// flags: new Set(reply[1]),
|
||||||
redirect: reply[3],
|
// redirect: reply[3],
|
||||||
prefixes: reply[5]
|
// prefixes: reply[5]
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
import { CommandRawReply, CommandReply, transformCommandReply } from './generic-transformers';
|
// import { CommandRawReply, CommandReply, transformCommandReply } from './generic-transformers';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(): RedisCommandArguments {
|
// export function transformArguments(): RedisCommandArguments {
|
||||||
return ['COMMAND'];
|
// return ['COMMAND'];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: Array<CommandRawReply>): Array<CommandReply> {
|
// export function transformReply(reply: Array<CommandRawReply>): Array<CommandReply> {
|
||||||
return reply.map(transformCommandReply);
|
// return reply.map(transformCommandReply);
|
||||||
}
|
// }
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(): RedisCommandArguments {
|
// export function transformArguments(): RedisCommandArguments {
|
||||||
return ['COMMAND', 'COUNT'];
|
// return ['COMMAND', 'COUNT'];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): number;
|
// export declare function transformReply(): number;
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(args: Array<RedisCommandArgument>): RedisCommandArguments {
|
// export function transformArguments(args: Array<RedisCommandArgument>): RedisCommandArguments {
|
||||||
return ['COMMAND', 'GETKEYS', ...args];
|
// return ['COMMAND', 'GETKEYS', ...args];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(args: Array<RedisCommandArgument>): RedisCommandArguments {
|
// export function transformArguments(args: Array<RedisCommandArgument>): RedisCommandArguments {
|
||||||
return ['COMMAND', 'GETKEYSANDFLAGS', ...args];
|
// return ['COMMAND', 'GETKEYSANDFLAGS', ...args];
|
||||||
}
|
// }
|
||||||
|
|
||||||
type KeysAndFlagsRawReply = Array<[
|
// type KeysAndFlagsRawReply = Array<[
|
||||||
RedisCommandArgument,
|
// RedisCommandArgument,
|
||||||
RedisCommandArguments
|
// RedisCommandArguments
|
||||||
]>;
|
// ]>;
|
||||||
|
|
||||||
type KeysAndFlagsReply = Array<{
|
// type KeysAndFlagsReply = Array<{
|
||||||
key: RedisCommandArgument;
|
// key: RedisCommandArgument;
|
||||||
flags: RedisCommandArguments;
|
// flags: RedisCommandArguments;
|
||||||
}>;
|
// }>;
|
||||||
|
|
||||||
export function transformReply(reply: KeysAndFlagsRawReply): KeysAndFlagsReply {
|
// export function transformReply(reply: KeysAndFlagsRawReply): KeysAndFlagsReply {
|
||||||
return reply.map(([key, flags]) => ({
|
// return reply.map(([key, flags]) => ({
|
||||||
key,
|
// key,
|
||||||
flags
|
// flags
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
import { CommandRawReply, CommandReply, transformCommandReply } from './generic-transformers';
|
// import { CommandRawReply, CommandReply, transformCommandReply } from './generic-transformers';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(commands: Array<string>): RedisCommandArguments {
|
// export function transformArguments(commands: Array<string>): RedisCommandArguments {
|
||||||
return ['COMMAND', 'INFO', ...commands];
|
// return ['COMMAND', 'INFO', ...commands];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: Array<CommandRawReply | null>): Array<CommandReply | null> {
|
// export function transformReply(reply: Array<CommandRawReply | null>): Array<CommandReply | null> {
|
||||||
return reply.map(command => command ? transformCommandReply(command) : null);
|
// return reply.map(command => command ? transformCommandReply(command) : null);
|
||||||
}
|
// }
|
||||||
|
@@ -1,31 +1,31 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export enum FilterBy {
|
// export enum FilterBy {
|
||||||
MODULE = 'MODULE',
|
// MODULE = 'MODULE',
|
||||||
ACLCAT = 'ACLCAT',
|
// ACLCAT = 'ACLCAT',
|
||||||
PATTERN = 'PATTERN'
|
// PATTERN = 'PATTERN'
|
||||||
}
|
// }
|
||||||
|
|
||||||
interface Filter {
|
// interface Filter {
|
||||||
filterBy: FilterBy;
|
// filterBy: FilterBy;
|
||||||
value: string;
|
// value: string;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
export function transformArguments(filter?: Filter): RedisCommandArguments {
|
// export function transformArguments(filter?: Filter): RedisCommandArguments {
|
||||||
const args = ['COMMAND', 'LIST'];
|
// const args = ['COMMAND', 'LIST'];
|
||||||
|
|
||||||
if (filter) {
|
// if (filter) {
|
||||||
args.push(
|
// args.push(
|
||||||
'FILTERBY',
|
// 'FILTERBY',
|
||||||
filter.filterBy,
|
// filter.filterBy,
|
||||||
filter.value
|
// filter.value
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<string>;
|
// export declare function transformReply(): Array<string>;
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
transformArguments(keys: RedisArgument | Array<RedisArgument>) {
|
transformArguments(keys: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['DEL'], keys);
|
return pushVariadicArguments(['DEL'], keys);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(keys: RedisArgument | Array<RedisArgument>) {
|
transformArguments(keys: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['EXISTS'], keys);
|
return pushVariadicArguments(['EXISTS'], keys);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(library: RedisArgument) {
|
transformArguments(library: RedisArgument) {
|
||||||
return ['FUNCTION', 'DELETE', library];
|
return ['FUNCTION', 'DELETE', library];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { BlobStringReply, Command } from '../RESP/types';
|
import { BlobStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['FUNCTION', 'DUMP'];
|
return ['FUNCTION', 'DUMP'];
|
||||||
},
|
},
|
||||||
|
@@ -2,8 +2,8 @@ import { SimpleStringReply, Command } from '../RESP/types';
|
|||||||
import { RedisFlushModes } from './FLUSHALL';
|
import { RedisFlushModes } from './FLUSHALL';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(mode?: RedisFlushModes) {
|
transformArguments(mode?: RedisFlushModes) {
|
||||||
const args = ['FUNCTION', 'FLUSH'];
|
const args = ['FUNCTION', 'FLUSH'];
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['FUNCTION', 'KILL'];
|
return ['FUNCTION', 'KILL'];
|
||||||
},
|
},
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
|
// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
|
||||||
|
|
||||||
export function transformArguments(pattern?: string): RedisCommandArguments {
|
// export function transformArguments(pattern?: string): RedisCommandArguments {
|
||||||
const args = ['FUNCTION', 'LIST'];
|
// const args = ['FUNCTION', 'LIST'];
|
||||||
|
|
||||||
if (pattern) {
|
// if (pattern) {
|
||||||
args.push(pattern);
|
// args.push(pattern);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: Array<FunctionListRawItemReply>): Array<FunctionListItemReply> {
|
// export function transformReply(reply: Array<FunctionListRawItemReply>): Array<FunctionListItemReply> {
|
||||||
return reply.map(transformFunctionListItemReply);
|
// return reply.map(transformFunctionListItemReply);
|
||||||
}
|
// }
|
||||||
|
@@ -1,26 +1,26 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
import { transformArguments as transformFunctionListArguments } from './FUNCTION_LIST';
|
// import { transformArguments as transformFunctionListArguments } from './FUNCTION_LIST';
|
||||||
import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
|
// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
|
||||||
|
|
||||||
export function transformArguments(pattern?: string): RedisCommandArguments {
|
// export function transformArguments(pattern?: string): RedisCommandArguments {
|
||||||
const args = transformFunctionListArguments(pattern);
|
// const args = transformFunctionListArguments(pattern);
|
||||||
args.push('WITHCODE');
|
// args.push('WITHCODE');
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
type FunctionListWithCodeRawItemReply = [
|
// type FunctionListWithCodeRawItemReply = [
|
||||||
...FunctionListRawItemReply,
|
// ...FunctionListRawItemReply,
|
||||||
'library_code',
|
// 'library_code',
|
||||||
string
|
// string
|
||||||
];
|
// ];
|
||||||
|
|
||||||
interface FunctionListWithCodeItemReply extends FunctionListItemReply {
|
// interface FunctionListWithCodeItemReply extends FunctionListItemReply {
|
||||||
libraryCode: string;
|
// libraryCode: string;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: Array<FunctionListWithCodeRawItemReply>): Array<FunctionListWithCodeItemReply> {
|
// export function transformReply(reply: Array<FunctionListWithCodeRawItemReply>): Array<FunctionListWithCodeItemReply> {
|
||||||
return reply.map(library => ({
|
// return reply.map(library => ({
|
||||||
...transformFunctionListItemReply(library as unknown as FunctionListRawItemReply),
|
// ...transformFunctionListItemReply(library as unknown as FunctionListRawItemReply),
|
||||||
libraryCode: library[7]
|
// libraryCode: library[7]
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
|
|
||||||
interface FunctionLoadOptions {
|
// interface FunctionLoadOptions {
|
||||||
REPLACE?: boolean;
|
// REPLACE?: boolean;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
code: string,
|
// code: string,
|
||||||
options?: FunctionLoadOptions
|
// options?: FunctionLoadOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = ['FUNCTION', 'LOAD'];
|
// const args = ['FUNCTION', 'LOAD'];
|
||||||
|
|
||||||
if (options?.REPLACE) {
|
// if (options?.REPLACE) {
|
||||||
args.push('REPLACE');
|
// args.push('REPLACE');
|
||||||
}
|
// }
|
||||||
|
|
||||||
args.push(code);
|
// args.push(code);
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): string;
|
// export declare function transformReply(): string;
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
dump: RedisCommandArgument,
|
// dump: RedisCommandArgument,
|
||||||
mode?: 'FLUSH' | 'APPEND' | 'REPLACE'
|
// mode?: 'FLUSH' | 'APPEND' | 'REPLACE'
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = ['FUNCTION', 'RESTORE', dump];
|
// const args = ['FUNCTION', 'RESTORE', dump];
|
||||||
|
|
||||||
if (mode) {
|
// if (mode) {
|
||||||
args.push(mode);
|
// args.push(mode);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): 'OK';
|
// export declare function transformReply(): 'OK';
|
||||||
|
@@ -1,53 +1,65 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { CommandArguments, RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { GeoCoordinates } from './generic-transformers';
|
import { GeoCoordinates } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
|
||||||
|
|
||||||
interface GeoMember extends GeoCoordinates {
|
interface GeoMember extends GeoCoordinates {
|
||||||
member: RedisCommandArgument;
|
member: RedisArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NX {
|
interface GeoAddOptions {
|
||||||
NX?: true;
|
condition: 'NX' | 'XX';
|
||||||
|
/**
|
||||||
|
* @deprecated Use `{ condition: 'NX' }` instead.
|
||||||
|
*/
|
||||||
|
NX?: boolean;
|
||||||
|
/**
|
||||||
|
* @deprecated Use `{ condition: 'XX' }` instead.
|
||||||
|
*/
|
||||||
|
XX?: boolean;
|
||||||
|
CH?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface XX {
|
export default {
|
||||||
XX?: true;
|
FIRST_KEY_INDEX: 1,
|
||||||
}
|
IS_READ_ONLY: false,
|
||||||
|
transformArguments(
|
||||||
type SetGuards = NX | XX;
|
key: RedisArgument,
|
||||||
|
toAdd: GeoMember | Array<GeoMember>,
|
||||||
interface GeoAddCommonOptions {
|
|
||||||
CH?: true;
|
|
||||||
}
|
|
||||||
|
|
||||||
type GeoAddOptions = SetGuards & GeoAddCommonOptions;
|
|
||||||
|
|
||||||
export function transformArguments(
|
|
||||||
key: RedisCommandArgument, toAdd: GeoMember | Array<GeoMember>,
|
|
||||||
options?: GeoAddOptions
|
options?: GeoAddOptions
|
||||||
): RedisCommandArguments {
|
) {
|
||||||
const args = ['GEOADD', key];
|
const args = ['GEOADD', key];
|
||||||
|
|
||||||
if ((options as NX)?.NX) {
|
if (options?.condition) {
|
||||||
args.push('NX');
|
args.push(options.condition);
|
||||||
} else if ((options as XX)?.XX) {
|
} else if (options?.NX) {
|
||||||
args.push('XX');
|
args.push('NX');
|
||||||
|
} else if (options?.XX) {
|
||||||
|
args.push('XX');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.CH) {
|
if (options?.CH) {
|
||||||
args.push('CH');
|
args.push('CH');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const { longitude, latitude, member } of (Array.isArray(toAdd) ? toAdd : [toAdd])) {
|
if (Array.isArray(toAdd)) {
|
||||||
args.push(
|
for (const member of toAdd) {
|
||||||
longitude.toString(),
|
pushMember(args, member);
|
||||||
latitude.toString(),
|
}
|
||||||
member
|
} else {
|
||||||
);
|
pushMember(args, toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
} as const satisfies Command;
|
||||||
|
|
||||||
export declare function transformReply(): number;
|
function pushMember(
|
||||||
|
args: CommandArguments,
|
||||||
|
{ longitude, latitude, member }: GeoMember
|
||||||
|
) {
|
||||||
|
args.push(
|
||||||
|
longitude.toString(),
|
||||||
|
latitude.toString(),
|
||||||
|
member
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||||
import { GeoUnits } from './generic-transformers';
|
import { GeoUnits } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export const IS_READ_ONLY = true;
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(
|
||||||
export function transformArguments(
|
key: RedisArgument,
|
||||||
key: RedisCommandArgument,
|
member1: RedisArgument,
|
||||||
member1: RedisCommandArgument,
|
member2: RedisArgument,
|
||||||
member2: RedisCommandArgument,
|
|
||||||
unit?: GeoUnits
|
unit?: GeoUnits
|
||||||
): RedisCommandArguments {
|
) {
|
||||||
const args = ['GEODIST', key, member1, member2];
|
const args = ['GEODIST', key, member1, member2];
|
||||||
|
|
||||||
if (unit) {
|
if (unit) {
|
||||||
@@ -18,8 +17,8 @@ export function transformArguments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
},
|
||||||
|
transformReply(reply: BlobStringReply | NullReply) {
|
||||||
export function transformReply(reply: RedisCommandArgument | null): number | null {
|
|
||||||
return reply === null ? null : Number(reply);
|
return reply === null ? null : Number(reply);
|
||||||
}
|
}
|
||||||
|
} as const satisfies Command;
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export const IS_READ_ONLY = true;
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(
|
||||||
export function transformArguments(
|
key: RedisArgument,
|
||||||
key: RedisCommandArgument,
|
member: RedisVariadicArgument
|
||||||
member: RedisCommandArgument | Array<RedisCommandArgument>
|
) {
|
||||||
): RedisCommandArguments {
|
|
||||||
return pushVariadicArguments(['GEOHASH', key], member);
|
return pushVariadicArguments(['GEOHASH', key], member);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
} as const satisfies Command;
|
||||||
|
@@ -1,27 +1,19 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { ArrayReply, BlobStringReply, NullReply, Command, RedisArgument } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export const IS_READ_ONLY = true;
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(
|
||||||
export function transformArguments(
|
key: RedisArgument,
|
||||||
key: RedisCommandArgument,
|
member: RedisVariadicArgument
|
||||||
member: RedisCommandArgument | Array<RedisCommandArgument>
|
) {
|
||||||
): RedisCommandArguments {
|
|
||||||
return pushVariadicArguments(['GEOPOS', key], member);
|
return pushVariadicArguments(['GEOPOS', key], member);
|
||||||
}
|
},
|
||||||
|
transformReply(reply: ArrayReply<[BlobStringReply, BlobStringReply] | NullReply>) {
|
||||||
type GeoCoordinatesRawReply = Array<[RedisCommandArgument, RedisCommandArgument] | null>;
|
return reply.map(item => item === null ? null : {
|
||||||
|
longitude: item[0],
|
||||||
interface GeoCoordinates {
|
latitude: item[1]
|
||||||
longitude: RedisCommandArgument;
|
|
||||||
latitude: RedisCommandArgument;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function transformReply(reply: GeoCoordinatesRawReply): Array<GeoCoordinates | null> {
|
|
||||||
return reply.map(coordinates => coordinates === null ? null : {
|
|
||||||
longitude: coordinates[0],
|
|
||||||
latitude: coordinates[1]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} as const satisfies Command;
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchOptions, GeoCoordinates, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
// import { GeoSearchOptions, GeoCoordinates, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
coordinates: GeoCoordinates,
|
// coordinates: GeoCoordinates,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoRadiusArguments(
|
// return pushGeoRadiusArguments(
|
||||||
['GEORADIUS'],
|
// ['GEORADIUS'],
|
||||||
key,
|
// key,
|
||||||
coordinates,
|
// coordinates,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchOptions, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
// import { GeoSearchOptions, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
member: string,
|
// member: string,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoRadiusArguments(
|
// return pushGeoRadiusArguments(
|
||||||
['GEORADIUSBYMEMBER'],
|
// ['GEORADIUSBYMEMBER'],
|
||||||
key,
|
// key,
|
||||||
member,
|
// member,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoUnits, GeoRadiusStoreOptions, pushGeoRadiusStoreArguments } from './generic-transformers';
|
// import { GeoUnits, GeoRadiusStoreOptions, pushGeoRadiusStoreArguments } from './generic-transformers';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
member: string,
|
// member: string,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
destination: RedisCommandArgument,
|
// destination: RedisCommandArgument,
|
||||||
options?: GeoRadiusStoreOptions,
|
// options?: GeoRadiusStoreOptions,
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoRadiusStoreArguments(
|
// return pushGeoRadiusStoreArguments(
|
||||||
['GEORADIUSBYMEMBER'],
|
// ['GEORADIUSBYMEMBER'],
|
||||||
key,
|
// key,
|
||||||
member,
|
// member,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
destination,
|
// destination,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): number
|
// export declare function transformReply(): number
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchOptions, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
// import { GeoSearchOptions, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
member: string,
|
// member: string,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoRadiusArguments(
|
// return pushGeoRadiusArguments(
|
||||||
['GEORADIUSBYMEMBER_RO'],
|
// ['GEORADIUSBYMEMBER_RO'],
|
||||||
key,
|
// key,
|
||||||
member,
|
// member,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoReplyWith, GeoSearchOptions, GeoUnits } from './generic-transformers';
|
// import { GeoReplyWith, GeoSearchOptions, GeoUnits } from './generic-transformers';
|
||||||
import { transformArguments as geoRadiusTransformArguments } from './GEORADIUSBYMEMBER_RO';
|
// import { transformArguments as geoRadiusTransformArguments } from './GEORADIUSBYMEMBER_RO';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER_RO';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER_RO';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
member: string,
|
// member: string,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
replyWith: Array<GeoReplyWith>,
|
// replyWith: Array<GeoReplyWith>,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = geoRadiusTransformArguments(
|
// const args: RedisCommandArguments = geoRadiusTransformArguments(
|
||||||
key,
|
// key,
|
||||||
member,
|
// member,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
|
|
||||||
args.push(...replyWith);
|
// args.push(...replyWith);
|
||||||
|
|
||||||
args.preserve = replyWith;
|
// args.preserve = replyWith;
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
// export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoReplyWith, GeoSearchOptions, GeoUnits } from './generic-transformers';
|
// import { GeoReplyWith, GeoSearchOptions, GeoUnits } from './generic-transformers';
|
||||||
import { transformArguments as transformGeoRadiusArguments } from './GEORADIUSBYMEMBER';
|
// import { transformArguments as transformGeoRadiusArguments } from './GEORADIUSBYMEMBER';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUSBYMEMBER';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
member: string,
|
// member: string,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
replyWith: Array<GeoReplyWith>,
|
// replyWith: Array<GeoReplyWith>,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = transformGeoRadiusArguments(
|
// const args: RedisCommandArguments = transformGeoRadiusArguments(
|
||||||
key,
|
// key,
|
||||||
member,
|
// member,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
|
|
||||||
args.push(...replyWith);
|
// args.push(...replyWith);
|
||||||
|
|
||||||
args.preserve = replyWith;
|
// args.preserve = replyWith;
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
// export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoCoordinates, GeoUnits, GeoRadiusStoreOptions, pushGeoRadiusStoreArguments } from './generic-transformers';
|
// import { GeoCoordinates, GeoUnits, GeoRadiusStoreOptions, pushGeoRadiusStoreArguments } from './generic-transformers';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
coordinates: GeoCoordinates,
|
// coordinates: GeoCoordinates,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
destination: RedisCommandArgument,
|
// destination: RedisCommandArgument,
|
||||||
options?: GeoRadiusStoreOptions,
|
// options?: GeoRadiusStoreOptions,
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoRadiusStoreArguments(
|
// return pushGeoRadiusStoreArguments(
|
||||||
['GEORADIUS'],
|
// ['GEORADIUS'],
|
||||||
key,
|
// key,
|
||||||
coordinates,
|
// coordinates,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
destination,
|
// destination,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): number;
|
// export declare function transformReply(): number;
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchOptions, GeoCoordinates, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
// import { GeoSearchOptions, GeoCoordinates, pushGeoRadiusArguments, GeoUnits } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
coordinates: GeoCoordinates,
|
// coordinates: GeoCoordinates,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoRadiusArguments(
|
// return pushGeoRadiusArguments(
|
||||||
['GEORADIUS_RO'],
|
// ['GEORADIUS_RO'],
|
||||||
key,
|
// key,
|
||||||
coordinates,
|
// coordinates,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoReplyWith, GeoSearchOptions, GeoCoordinates, GeoUnits } from './generic-transformers';
|
// import { GeoReplyWith, GeoSearchOptions, GeoCoordinates, GeoUnits } from './generic-transformers';
|
||||||
import { transformArguments as transformGeoRadiusRoArguments } from './GEORADIUS_RO';
|
// import { transformArguments as transformGeoRadiusRoArguments } from './GEORADIUS_RO';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS_RO';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS_RO';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
coordinates: GeoCoordinates,
|
// coordinates: GeoCoordinates,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
replyWith: Array<GeoReplyWith>,
|
// replyWith: Array<GeoReplyWith>,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = transformGeoRadiusRoArguments(
|
// const args: RedisCommandArguments = transformGeoRadiusRoArguments(
|
||||||
key,
|
// key,
|
||||||
coordinates,
|
// coordinates,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
|
|
||||||
args.push(...replyWith);
|
// args.push(...replyWith);
|
||||||
|
|
||||||
args.preserve = replyWith;
|
// args.preserve = replyWith;
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
// export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoReplyWith, GeoSearchOptions, GeoCoordinates, GeoUnits } from './generic-transformers';
|
// import { GeoReplyWith, GeoSearchOptions, GeoCoordinates, GeoUnits } from './generic-transformers';
|
||||||
import { transformArguments as transformGeoRadiusArguments } from './GEORADIUS';
|
// import { transformArguments as transformGeoRadiusArguments } from './GEORADIUS';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEORADIUS';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
coordinates: GeoCoordinates,
|
// coordinates: GeoCoordinates,
|
||||||
radius: number,
|
// radius: number,
|
||||||
unit: GeoUnits,
|
// unit: GeoUnits,
|
||||||
replyWith: Array<GeoReplyWith>,
|
// replyWith: Array<GeoReplyWith>,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = transformGeoRadiusArguments(
|
// const args: RedisCommandArguments = transformGeoRadiusArguments(
|
||||||
key,
|
// key,
|
||||||
coordinates,
|
// coordinates,
|
||||||
radius,
|
// radius,
|
||||||
unit,
|
// unit,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
|
|
||||||
args.push(...replyWith);
|
// args.push(...replyWith);
|
||||||
|
|
||||||
args.preserve = replyWith;
|
// args.preserve = replyWith;
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
// export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
|
// import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
from: GeoSearchFrom,
|
// from: GeoSearchFrom,
|
||||||
by: GeoSearchBy,
|
// by: GeoSearchBy,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushGeoSearchArguments(['GEOSEARCH'], key, from, by, options);
|
// return pushGeoSearchArguments(['GEOSEARCH'], key, from, by, options);
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,38 +1,38 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
|
// import { GeoSearchFrom, GeoSearchBy, GeoSearchOptions, pushGeoSearchArguments } from './generic-transformers';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEOSEARCH';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEOSEARCH';
|
||||||
|
|
||||||
interface GeoSearchStoreOptions extends GeoSearchOptions {
|
// interface GeoSearchStoreOptions extends GeoSearchOptions {
|
||||||
STOREDIST?: true;
|
// STOREDIST?: true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
destination: RedisCommandArgument,
|
// destination: RedisCommandArgument,
|
||||||
source: RedisCommandArgument,
|
// source: RedisCommandArgument,
|
||||||
from: GeoSearchFrom,
|
// from: GeoSearchFrom,
|
||||||
by: GeoSearchBy,
|
// by: GeoSearchBy,
|
||||||
options?: GeoSearchStoreOptions
|
// options?: GeoSearchStoreOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = pushGeoSearchArguments(
|
// const args = pushGeoSearchArguments(
|
||||||
['GEOSEARCHSTORE', destination],
|
// ['GEOSEARCHSTORE', destination],
|
||||||
source,
|
// source,
|
||||||
from,
|
// from,
|
||||||
by,
|
// by,
|
||||||
options
|
// options
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (options?.STOREDIST) {
|
// if (options?.STOREDIST) {
|
||||||
args.push('STOREDIST');
|
// args.push('STOREDIST');
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: number): number {
|
// export function transformReply(reply: number): number {
|
||||||
if (typeof reply !== 'number') {
|
// if (typeof reply !== 'number') {
|
||||||
throw new TypeError(`https://github.com/redis/redis/issues/9261`);
|
// throw new TypeError(`https://github.com/redis/redis/issues/9261`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return reply;
|
// return reply;
|
||||||
}
|
// }
|
||||||
|
@@ -1,23 +1,23 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { GeoSearchFrom, GeoSearchBy, GeoReplyWith, GeoSearchOptions } from './generic-transformers';
|
// import { GeoSearchFrom, GeoSearchBy, GeoReplyWith, GeoSearchOptions } from './generic-transformers';
|
||||||
import { transformArguments as geoSearchTransformArguments } from './GEOSEARCH';
|
// import { transformArguments as geoSearchTransformArguments } from './GEOSEARCH';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEOSEARCH';
|
// export { FIRST_KEY_INDEX, IS_READ_ONLY } from './GEOSEARCH';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
from: GeoSearchFrom,
|
// from: GeoSearchFrom,
|
||||||
by: GeoSearchBy,
|
// by: GeoSearchBy,
|
||||||
replyWith: Array<GeoReplyWith>,
|
// replyWith: Array<GeoReplyWith>,
|
||||||
options?: GeoSearchOptions
|
// options?: GeoSearchOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args: RedisCommandArguments = geoSearchTransformArguments(key, from, by, options);
|
// const args: RedisCommandArguments = geoSearchTransformArguments(key, from, by, options);
|
||||||
|
|
||||||
args.push(...replyWith);
|
// args.push(...replyWith);
|
||||||
|
|
||||||
args.preserve = replyWith;
|
// args.preserve = replyWith;
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
// export { transformGeoMembersWithReply as transformReply } from './generic-transformers';
|
||||||
|
@@ -1,15 +1,11 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { NumberReply, Command, RedisArgument } from '../RESP/types';
|
||||||
import { BitValue } from './generic-transformers';
|
import { BitValue } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export const IS_READ_ONLY = true;
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(key: RedisArgument, offset: number) {
|
||||||
export function transformArguments(
|
|
||||||
key: RedisCommandArgument,
|
|
||||||
offset: number
|
|
||||||
): RedisCommandArguments {
|
|
||||||
return ['GETBIT', key, offset.toString()];
|
return ['GETBIT', key, offset.toString()];
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply<BitValue>
|
||||||
export declare function transformReply(): BitValue;
|
} as const satisfies Command;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { RedisArgument, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, BlobStringReply, Command } from '../RESP/types';
|
||||||
import { ScanOptions, pushScanArguments } from './generic-transformers';
|
import { ScanCommonOptions, pushScanArguments } from './SCAN';
|
||||||
|
|
||||||
export interface HScanEntry {
|
export interface HScanEntry {
|
||||||
field: BlobStringReply;
|
field: BlobStringReply;
|
||||||
@@ -12,7 +12,7 @@ export default {
|
|||||||
transformArguments(
|
transformArguments(
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
cursor: number,
|
cursor: number,
|
||||||
options?: ScanOptions
|
options?: ScanCommonOptions
|
||||||
) {
|
) {
|
||||||
return pushScanArguments(['HSCAN', key], cursor, options);
|
return pushScanArguments(['HSCAN', key], cursor, options);
|
||||||
},
|
},
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
// import { RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export type EventType =
|
// export type EventType =
|
||||||
'active-defrag-cycle'
|
// 'active-defrag-cycle'
|
||||||
| 'aof-fsync-always'
|
// | 'aof-fsync-always'
|
||||||
| 'aof-stat'
|
// | 'aof-stat'
|
||||||
| 'aof-rewrite-diff-write'
|
// | 'aof-rewrite-diff-write'
|
||||||
| 'aof-rename'
|
// | 'aof-rename'
|
||||||
| 'aof-write'
|
// | 'aof-write'
|
||||||
| 'aof-write-active-child'
|
// | 'aof-write-active-child'
|
||||||
| 'aof-write-alone'
|
// | 'aof-write-alone'
|
||||||
| 'aof-write-pending-fsync'
|
// | 'aof-write-pending-fsync'
|
||||||
| 'command'
|
// | 'command'
|
||||||
| 'expire-cycle'
|
// | 'expire-cycle'
|
||||||
| 'eviction-cycle'
|
// | 'eviction-cycle'
|
||||||
| 'eviction-del'
|
// | 'eviction-del'
|
||||||
| 'fast-command'
|
// | 'fast-command'
|
||||||
| 'fork'
|
// | 'fork'
|
||||||
| 'rdb-unlink-temp-file';
|
// | 'rdb-unlink-temp-file';
|
||||||
|
|
||||||
export function transformArguments(event: EventType): RedisCommandArguments {
|
// export function transformArguments(event: EventType): RedisCommandArguments {
|
||||||
return ['LATENCY', 'GRAPH', event];
|
// return ['LATENCY', 'GRAPH', event];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): string;
|
// export declare function transformReply(): string;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { RedisArgument, NullReply, TuplesReply, BlobStringReply, Command } from '../RESP/types';
|
import { NullReply, TuplesReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
import { transformLMPopArguments, LMPopOptions, ListSide } from './generic-transformers';
|
import { transformLMPopArguments, LMPopOptions, ListSide, RedisVariadicArgument } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 2,
|
FIRST_KEY_INDEX: 2,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
keys: RedisArgument | Array<RedisArgument>,
|
keys: RedisVariadicArgument,
|
||||||
side: ListSide,
|
side: ListSide,
|
||||||
options?: LMPopOptions
|
options?: LMPopOptions
|
||||||
) {
|
) {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { BlobStringReply, Command } from '../RESP/types';
|
import { BlobStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(version?: number, ...optionalArguments: Array<number>) {
|
transformArguments(version?: number, ...optionalArguments: Array<number>) {
|
||||||
const args = ['LOLWUT'];
|
const args = ['LOLWUT'];
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { RedisArgument, NullReply, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, NullReply, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: false,
|
|
||||||
FIRST_KEY_INDEX: 2,
|
FIRST_KEY_INDEX: 2,
|
||||||
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, count: number) {
|
transformArguments(key: RedisArgument, count: number) {
|
||||||
return ['LPOP', key, count.toString()];
|
return ['LPOP', key, count.toString()];
|
||||||
},
|
},
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
transformArguments(key: RedisArgument, elements: RedisArgument | Array<RedisArgument>) {
|
transformArguments(key: RedisArgument, elements: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['LPUSH', key], elements);
|
return pushVariadicArguments(['LPUSH', key], elements);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
transformArguments(key: RedisArgument, elements: RedisArgument | Array<RedisArgument>) {
|
transformArguments(key: RedisArgument, elements: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['LPUSHX', key], elements);
|
return pushVariadicArguments(['LPUSHX', key], elements);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
@@ -6,8 +6,8 @@ export type ModuleListReply = ArrayReply<TuplesToMapReply<[
|
|||||||
]>>;
|
]>>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['MODULE', 'LIST'];
|
return ['MODULE', 'LIST'];
|
||||||
},
|
},
|
||||||
|
@@ -2,10 +2,16 @@ import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
|||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(path: RedisArgument, moduleArguments?: Array<RedisArgument>) {
|
transformArguments(path: RedisArgument, moduleArguments?: Array<RedisArgument>) {
|
||||||
return pushVariadicArguments(['MODULE', 'LOAD', path], moduleArguments);
|
const args = ['MODULE', 'LOAD', path];
|
||||||
|
|
||||||
|
if (moduleArguments) {
|
||||||
|
return args.concat(moduleArguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply
|
transformReply: undefined as unknown as () => SimpleStringReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(name: RedisArgument) {
|
transformArguments(name: RedisArgument) {
|
||||||
return ['MODULE', 'UNLOAD', name];
|
return ['MODULE', 'UNLOAD', name];
|
||||||
},
|
},
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, element?: RedisArgument | Array<RedisArgument>) {
|
transformArguments(key: RedisArgument, element?: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['PFADD', key], element);
|
const args = ['PFADD', key];
|
||||||
|
if (!element) return args;
|
||||||
|
|
||||||
|
return pushVariadicArguments(args, element);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key?: RedisArgument | Array<RedisArgument>) {
|
transformArguments(key: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['PFCOUNT'], key);
|
return pushVariadicArguments(['PFCOUNT'], key);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
destination: RedisArgument,
|
destination: RedisArgument,
|
||||||
source?: RedisArgument | Array<RedisArgument>
|
source?: RedisVariadicArgument
|
||||||
) {
|
) {
|
||||||
return pushVariadicArguments(['PFMERGE', destination], source);
|
const args = ['PFMERGE', destination];
|
||||||
|
if (!source) return args;
|
||||||
|
|
||||||
|
return pushVariadicArguments(args, source);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply
|
transformReply: undefined as unknown as () => SimpleStringReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(channel: RedisArgument, message: RedisArgument) {
|
transformArguments(channel: RedisArgument, message: RedisArgument) {
|
||||||
return ['PUBLISH', channel, message];
|
return ['PUBLISH', channel, message];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(pattern?: RedisArgument) {
|
transformArguments(pattern?: RedisArgument) {
|
||||||
const args: Array<RedisArgument> = ['PUBSUB', 'CHANNELS'];
|
const args: Array<RedisArgument> = ['PUBSUB', 'CHANNELS'];
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { NumberReply, Command } from '../RESP/types';
|
import { NumberReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['PUBSUB', 'NUMPAT'];
|
return ['PUBSUB', 'NUMPAT'];
|
||||||
},
|
},
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, NumberReply, Command } from '../RESP/types';
|
import { ArrayReply, BlobStringReply, NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
transformArguments(channels?: RedisArgument | Array<RedisArgument>) {
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(channels?: RedisVariadicArgument) {
|
||||||
const args = ['PUBSUB', 'NUMSUB'];
|
const args = ['PUBSUB', 'NUMSUB'];
|
||||||
|
|
||||||
if (channels) return pushVariadicArguments(args, channels);
|
if (channels) return pushVariadicArguments(args, channels);
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(pattern?: RedisArgument) {
|
transformArguments(pattern?: RedisArgument) {
|
||||||
const args: Array<RedisArgument> = ['PUBSUB', 'bb'];
|
const args: Array<RedisArgument> = ['PUBSUB', 'bb'];
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['READONLY'];
|
return ['READONLY'];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['READWRITE'];
|
return ['READWRITE'];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(host: string, port: number) {
|
transformArguments(host: string, port: number) {
|
||||||
return ['REPLICAOF', host, port.toString()];
|
return ['REPLICAOF', host, port.toString()];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['RESTORE-ASKING'];
|
return ['RESTORE-ASKING'];
|
||||||
},
|
},
|
||||||
|
@@ -22,8 +22,8 @@ type SentinelRole = [
|
|||||||
type Role = MasterRole | SlaveRole | SentinelRole;
|
type Role = MasterRole | SlaveRole | SentinelRole;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['ROLE'];
|
return ['ROLE'];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['SAVE'];
|
return ['SAVE'];
|
||||||
},
|
},
|
||||||
|
@@ -1,84 +1,62 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments, transformReply } from './SCAN';
|
import SCAN from './SCAN';
|
||||||
|
|
||||||
describe('SCAN', () => {
|
describe('SCAN', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('cusror only', () => {
|
it('cusror only', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(0),
|
SCAN.transformArguments(0),
|
||||||
['SCAN', '0']
|
['SCAN', '0']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with MATCH', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(0, {
|
|
||||||
MATCH: 'pattern'
|
|
||||||
}),
|
|
||||||
['SCAN', '0', 'MATCH', 'pattern']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with COUNT', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(0, {
|
|
||||||
COUNT: 1
|
|
||||||
}),
|
|
||||||
['SCAN', '0', 'COUNT', '1']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with TYPE', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(0, {
|
|
||||||
TYPE: 'stream'
|
|
||||||
}),
|
|
||||||
['SCAN', '0', 'TYPE', 'stream']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with MATCH & COUNT & TYPE', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(0, {
|
|
||||||
MATCH: 'pattern',
|
|
||||||
COUNT: 1,
|
|
||||||
TYPE: 'stream'
|
|
||||||
}),
|
|
||||||
['SCAN', '0', 'MATCH', 'pattern', 'COUNT', '1', 'TYPE', 'stream']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('transformReply', () => {
|
it('with MATCH', () => {
|
||||||
it('without keys', () => {
|
assert.deepEqual(
|
||||||
assert.deepEqual(
|
SCAN.transformArguments(0, {
|
||||||
transformReply(['0', []]),
|
MATCH: 'pattern'
|
||||||
{
|
}),
|
||||||
cursor: 0,
|
['SCAN', '0', 'MATCH', 'pattern']
|
||||||
keys: []
|
);
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with keys', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformReply(['0', ['key']]),
|
|
||||||
{
|
|
||||||
cursor: 0,
|
|
||||||
keys: ['key']
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.scan', async client => {
|
it('with COUNT', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.scan(0),
|
SCAN.transformArguments(0, {
|
||||||
{
|
COUNT: 1
|
||||||
cursor: 0,
|
}),
|
||||||
keys: []
|
['SCAN', '0', 'COUNT', '1']
|
||||||
}
|
);
|
||||||
);
|
});
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
|
||||||
|
it('with TYPE', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
SCAN.transformArguments(0, {
|
||||||
|
TYPE: 'stream'
|
||||||
|
}),
|
||||||
|
['SCAN', '0', 'TYPE', 'stream']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('with MATCH & COUNT & TYPE', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
SCAN.transformArguments(0, {
|
||||||
|
MATCH: 'pattern',
|
||||||
|
COUNT: 1,
|
||||||
|
TYPE: 'stream'
|
||||||
|
}),
|
||||||
|
['SCAN', '0', 'MATCH', 'pattern', 'COUNT', '1', 'TYPE', 'stream']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.scan', async client => {
|
||||||
|
assert.deepEqual(
|
||||||
|
await client.scan(0),
|
||||||
|
{
|
||||||
|
cursor: 0,
|
||||||
|
keys: []
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,13 +1,35 @@
|
|||||||
import { RedisArgument, BlobStringReply, ArrayReply, Command } from '../RESP/types';
|
import { CommandArguments, RedisArgument, BlobStringReply, ArrayReply, Command } from '../RESP/types';
|
||||||
import { ScanOptions, pushScanArguments } from './generic-transformers';
|
|
||||||
|
|
||||||
export interface ScanCommandOptions extends ScanOptions {
|
export interface ScanCommonOptions {
|
||||||
|
MATCH?: string;
|
||||||
|
COUNT?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pushScanArguments(
|
||||||
|
args: CommandArguments,
|
||||||
|
cursor: number,
|
||||||
|
options?: ScanOptions
|
||||||
|
): CommandArguments {
|
||||||
|
args.push(cursor.toString());
|
||||||
|
|
||||||
|
if (options?.MATCH) {
|
||||||
|
args.push('MATCH', options.MATCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.COUNT) {
|
||||||
|
args.push('COUNT', options.COUNT.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScanOptions extends ScanCommonOptions {
|
||||||
TYPE?: RedisArgument;
|
TYPE?: RedisArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(cursor: number, options?: ScanCommandOptions) {
|
transformArguments(cursor: number, options?: ScanOptions) {
|
||||||
const args = pushScanArguments(['SCAN'], cursor, options);
|
const args = pushScanArguments(['SCAN'], cursor, options);
|
||||||
|
|
||||||
if (options?.TYPE) {
|
if (options?.TYPE) {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(mode: 'YES' | 'SYNC' | 'NO') {
|
transformArguments(mode: 'YES' | 'SYNC' | 'NO') {
|
||||||
return ['SCRIPT', 'DEBUG', mode];
|
return ['SCRIPT', 'DEBUG', mode];
|
||||||
},
|
},
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { RedisArgument, ArrayReply, NumberReply, Command } from '../RESP/types';
|
import { ArrayReply, NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
transformArguments(sha1: RedisArgument | Array<RedisArgument>) {
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(sha1: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['SCRIPT', 'EXISTS'], sha1);
|
return pushVariadicArguments(['SCRIPT', 'EXISTS'], sha1);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(mode?: 'ASYNC' | 'SYNC') {
|
transformArguments(mode?: 'ASYNC' | 'SYNC') {
|
||||||
const args = ['SCRIPT', 'FLUSH'];
|
const args = ['SCRIPT', 'FLUSH'];
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { SimpleStringReply, Command } from '../RESP/types';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments() {
|
transformArguments() {
|
||||||
return ['SCRIPT', 'KILL'];
|
return ['SCRIPT', 'KILL'];
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { BlobStringReply, Command, RedisArgument } from '../RESP/types';
|
import { BlobStringReply, Command, RedisArgument } from '../RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: true,
|
|
||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
transformArguments(script: RedisArgument) {
|
transformArguments(script: RedisArgument) {
|
||||||
return ['SCRIPT', 'LOAD', script];
|
return ['SCRIPT', 'LOAD', script];
|
||||||
},
|
},
|
||||||
|
@@ -2,8 +2,8 @@ import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
|||||||
import { BitValue } from './generic-transformers';
|
import { BitValue } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
IS_READ_ONLY: false,
|
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
offset: number,
|
offset: number,
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: false,
|
||||||
destination: RedisCommandArgument,
|
transformArguments(
|
||||||
keys: RedisCommandArgument | Array<RedisCommandArgument>
|
destination: RedisArgument,
|
||||||
): RedisCommandArguments {
|
keys: RedisVariadicArgument
|
||||||
|
) {
|
||||||
return pushVariadicArguments(['SINTERSTORE', destination], keys);
|
return pushVariadicArguments(['SINTERSTORE', destination], keys);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
} as const satisfies Command;
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { NumberReply, Command, RedisArgument } from '../RESP/types';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: true,
|
||||||
key: RedisCommandArgument,
|
transformArguments(key: RedisArgument, member: RedisArgument) {
|
||||||
member: RedisCommandArgument
|
|
||||||
): RedisCommandArguments {
|
|
||||||
return ['SISMEMBER', key, member];
|
return ['SISMEMBER', key, member];
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
} as const satisfies Command;
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { RedisArgument, ArrayReply, NumberReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: true,
|
||||||
key: RedisCommandArgument,
|
transformArguments(key: RedisArgument, members: Array<RedisArgument>) {
|
||||||
members: Array<RedisCommandArgument>
|
|
||||||
): RedisCommandArguments {
|
|
||||||
return ['SMISMEMBER', key, ...members];
|
return ['SMISMEMBER', key, ...members];
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||||
export { transformBooleanArrayReply as transformReply } from './generic-transformers';
|
} as const satisfies Command;
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
source: RedisCommandArgument,
|
// source: RedisCommandArgument,
|
||||||
destination: RedisCommandArgument,
|
// destination: RedisCommandArgument,
|
||||||
member: RedisCommandArgument
|
// member: RedisCommandArgument
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return ['SMOVE', source, destination, member];
|
// return ['SMOVE', source, destination, member];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export { transformBooleanReply as transformReply } from './generic-transformers';
|
// export { transformBooleanReply as transformReply } from './generic-transformers';
|
||||||
|
@@ -1,13 +1,59 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
import { pushSortArguments, SortOptions } from './generic-transformers';
|
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export interface SortOptions {
|
||||||
|
BY?: string;
|
||||||
export function transformArguments(
|
LIMIT?: {
|
||||||
key: string,
|
offset: number;
|
||||||
options?: SortOptions
|
count: number;
|
||||||
): RedisCommandArguments {
|
},
|
||||||
return pushSortArguments(['SORT', key], options);
|
GET?: string | Array<string>;
|
||||||
|
DIRECTION?: 'ASC' | 'DESC';
|
||||||
|
ALPHA?: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare function transformReply(): Array<string>;
|
export function transformSortArguments(
|
||||||
|
command: RedisArgument,
|
||||||
|
options?: SortOptions
|
||||||
|
) {
|
||||||
|
const args = [command];
|
||||||
|
|
||||||
|
if (options?.BY) {
|
||||||
|
args.push('BY', options.BY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.LIMIT) {
|
||||||
|
args.push(
|
||||||
|
'LIMIT',
|
||||||
|
options.LIMIT.offset.toString(),
|
||||||
|
options.LIMIT.count.toString()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.GET) {
|
||||||
|
if (typeof options.GET === 'string') {
|
||||||
|
args.push('GET', options.GET);
|
||||||
|
} else {
|
||||||
|
for (const pattern of options.GET) {
|
||||||
|
args.push('GET', pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.DIRECTION) {
|
||||||
|
args.push(options.DIRECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.ALPHA) {
|
||||||
|
args.push('ALPHA');
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments: transformSortArguments.bind(undefined, 'SORT'),
|
||||||
|
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||||
|
} as const satisfies Command;
|
||||||
|
|
||||||
|
@@ -1,15 +1,9 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
import { Command } from '../RESP/types';
|
||||||
import { pushSortArguments, SortOptions } from "./generic-transformers";
|
import SORT, { transformSortArguments } from './SORT';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: SORT.FIRST_KEY_INDEX,
|
||||||
export const IS_READ_ONLY = true;
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments: transformSortArguments.bind(undefined, 'SORT_RO'),
|
||||||
export function transformArguments(
|
transformReply: SORT.transformReply
|
||||||
key: string,
|
} as const satisfies Command;
|
||||||
options?: SortOptions
|
|
||||||
): RedisCommandArguments {
|
|
||||||
return pushSortArguments(['SORT_RO', key], options);
|
|
||||||
}
|
|
||||||
|
|
||||||
export declare function transformReply(): Array<string>;
|
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { SortOptions } from './generic-transformers';
|
import { SortOptions, transformSortArguments } from './SORT';
|
||||||
import { transformArguments as transformSortArguments } from './SORT';
|
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: false,
|
||||||
source: string,
|
transformArguments(
|
||||||
destination: string,
|
source: RedisArgument,
|
||||||
|
destination: RedisArgument,
|
||||||
options?: SortOptions
|
options?: SortOptions
|
||||||
): RedisCommandArguments {
|
) {
|
||||||
const args = transformSortArguments(source, options);
|
const args = transformSortArguments(source, options);
|
||||||
args.push('STORE', destination);
|
args.push('STORE', destination);
|
||||||
return args;
|
return args;
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): number;
|
} as const satisfies Command;
|
||||||
|
@@ -1,18 +1,18 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
count?: number
|
// count?: number
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = ['SPOP', key];
|
// const args = ['SPOP', key];
|
||||||
|
|
||||||
if (typeof count === 'number') {
|
// if (typeof count === 'number') {
|
||||||
args.push(count.toString());
|
// args.push(count.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,14 +1,10 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export const FIRST_KEY_INDEX = 1;
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(channel: RedisArgument, message: RedisArgument) {
|
||||||
export function transformArguments(
|
|
||||||
channel: RedisCommandArgument,
|
|
||||||
message: RedisCommandArgument
|
|
||||||
): RedisCommandArguments {
|
|
||||||
return ['SPUBLISH', channel, message];
|
return ['SPUBLISH', channel, message];
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): number;
|
} as const satisfies Command;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(key: RedisArgument) {
|
||||||
return ['SRANDMEMBER', key];
|
return ['SRANDMEMBER', key];
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => BlobStringReply | NullReply
|
||||||
export declare function transformReply(): RedisCommandArgument | null;
|
} as const satisfies Command;
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { transformArguments as transformSRandMemberArguments } from './SRANDMEMBER';
|
// import { transformArguments as transformSRandMemberArguments } from './SRANDMEMBER';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX } from './SRANDMEMBER';
|
// export { FIRST_KEY_INDEX } from './SRANDMEMBER';
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
count: number
|
// count: number
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return [
|
// return [
|
||||||
...transformSRandMemberArguments(key),
|
// ...transformSRandMemberArguments(key),
|
||||||
count.toString()
|
// count.toString()
|
||||||
];
|
// ];
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { NumberReply, Command, RedisArgument } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: false,
|
||||||
key: RedisCommandArgument,
|
transformArguments(key: RedisArgument, members: RedisVariadicArgument) {
|
||||||
members: RedisCommandArgument | Array<RedisCommandArgument>
|
|
||||||
): RedisCommandArguments {
|
|
||||||
return pushVariadicArguments(['SREM', key], members);
|
return pushVariadicArguments(['SREM', key], members);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): number;
|
} as const satisfies Command;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { RedisArgument, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, BlobStringReply, Command } from '../RESP/types';
|
||||||
import { ScanOptions, pushScanArguments } from './generic-transformers';
|
import { ScanCommonOptions, pushScanArguments } from './SCAN';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
@@ -7,7 +7,7 @@ export default {
|
|||||||
transformArguments(
|
transformArguments(
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
cursor: number,
|
cursor: number,
|
||||||
options?: ScanOptions
|
options?: ScanCommonOptions
|
||||||
) {
|
) {
|
||||||
return pushScanArguments(['SSCAN', key], cursor, options);
|
return pushScanArguments(['SSCAN', key], cursor, options);
|
||||||
},
|
},
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
// import { pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
// export const IS_READ_ONLY = true;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
keys: RedisCommandArgument | Array<RedisCommandArgument>
|
// keys: RedisCommandArgument | Array<RedisCommandArgument>
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushVariadicArguments(['SUNION'], keys);
|
// return pushVariadicArguments(['SUNION'], keys);
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): Array<RedisCommandArgument>;
|
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
// import { pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
destination: RedisCommandArgument,
|
// destination: RedisCommandArgument,
|
||||||
keys: RedisCommandArgument | Array<RedisCommandArgument>
|
// keys: RedisCommandArgument | Array<RedisCommandArgument>
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushVariadicArguments(['SUNIONSTORE', destination], keys);
|
// return pushVariadicArguments(['SUNIONSTORE', destination], keys);
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): number;
|
// export declare function transformReply(): number;
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: false,
|
||||||
key: RedisCommandArgument | Array<RedisCommandArgument>
|
transformArguments(key: RedisVariadicArgument) {
|
||||||
): RedisCommandArguments {
|
|
||||||
return pushVariadicArguments(['TOUCH'], key);
|
return pushVariadicArguments(['TOUCH'], key);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): number;
|
} as const satisfies Command;
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(
|
IS_READ_ONLY: false,
|
||||||
key: RedisCommandArgument | Array<RedisCommandArgument>
|
transformArguments(key: RedisVariadicArgument) {
|
||||||
): RedisCommandArguments {
|
|
||||||
return pushVariadicArguments(['UNLINK'], key);
|
return pushVariadicArguments(['UNLINK'], key);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): number;
|
} as const satisfies Command;
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { RedisCommandArguments } from '.';
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(key: string | Array<string>): RedisCommandArguments {
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(key: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['WATCH'], key);
|
return pushVariadicArguments(['WATCH'], key);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => SimpleStringReply
|
||||||
export declare function transformReply(): string;
|
} as const satisfies Command;
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
// import { pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
group: RedisCommandArgument,
|
// group: RedisCommandArgument,
|
||||||
id: RedisCommandArgument | Array<RedisCommandArgument>
|
// id: RedisCommandArgument | Array<RedisCommandArgument>
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
return pushVariadicArguments(['XACK', key, group], id);
|
// return pushVariadicArguments(['XACK', key, group], id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): number;
|
// export declare function transformReply(): number;
|
||||||
|
@@ -1,52 +1,52 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
interface XAddOptions {
|
// interface XAddOptions {
|
||||||
NOMKSTREAM?: true;
|
// NOMKSTREAM?: true;
|
||||||
TRIM?: {
|
// TRIM?: {
|
||||||
strategy?: 'MAXLEN' | 'MINID';
|
// strategy?: 'MAXLEN' | 'MINID';
|
||||||
strategyModifier?: '=' | '~';
|
// strategyModifier?: '=' | '~';
|
||||||
threshold: number;
|
// threshold: number;
|
||||||
limit?: number;
|
// limit?: number;
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
id: RedisCommandArgument,
|
// id: RedisCommandArgument,
|
||||||
message: Record<string, RedisCommandArgument>,
|
// message: Record<string, RedisCommandArgument>,
|
||||||
options?: XAddOptions
|
// options?: XAddOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = ['XADD', key];
|
// const args = ['XADD', key];
|
||||||
|
|
||||||
if (options?.NOMKSTREAM) {
|
// if (options?.NOMKSTREAM) {
|
||||||
args.push('NOMKSTREAM');
|
// args.push('NOMKSTREAM');
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (options?.TRIM) {
|
// if (options?.TRIM) {
|
||||||
if (options.TRIM.strategy) {
|
// if (options.TRIM.strategy) {
|
||||||
args.push(options.TRIM.strategy);
|
// args.push(options.TRIM.strategy);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (options.TRIM.strategyModifier) {
|
// if (options.TRIM.strategyModifier) {
|
||||||
args.push(options.TRIM.strategyModifier);
|
// args.push(options.TRIM.strategyModifier);
|
||||||
}
|
// }
|
||||||
|
|
||||||
args.push(options.TRIM.threshold.toString());
|
// args.push(options.TRIM.threshold.toString());
|
||||||
|
|
||||||
if (options.TRIM.limit) {
|
// if (options.TRIM.limit) {
|
||||||
args.push('LIMIT', options.TRIM.limit.toString());
|
// args.push('LIMIT', options.TRIM.limit.toString());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
args.push(id);
|
// args.push(id);
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(message)) {
|
// for (const [key, value] of Object.entries(message)) {
|
||||||
args.push(key, value);
|
// args.push(key, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): string;
|
// export declare function transformReply(): string;
|
||||||
|
@@ -1,39 +1,39 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { StreamMessagesReply, transformStreamMessagesReply } from './generic-transformers';
|
// import { StreamMessagesReply, transformStreamMessagesReply } from './generic-transformers';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
// export const FIRST_KEY_INDEX = 1;
|
||||||
|
|
||||||
export interface XAutoClaimOptions {
|
// export interface XAutoClaimOptions {
|
||||||
COUNT?: number;
|
// COUNT?: number;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformArguments(
|
// export function transformArguments(
|
||||||
key: RedisCommandArgument,
|
// key: RedisCommandArgument,
|
||||||
group: RedisCommandArgument,
|
// group: RedisCommandArgument,
|
||||||
consumer: RedisCommandArgument,
|
// consumer: RedisCommandArgument,
|
||||||
minIdleTime: number,
|
// minIdleTime: number,
|
||||||
start: string,
|
// start: string,
|
||||||
options?: XAutoClaimOptions
|
// options?: XAutoClaimOptions
|
||||||
): RedisCommandArguments {
|
// ): RedisCommandArguments {
|
||||||
const args = ['XAUTOCLAIM', key, group, consumer, minIdleTime.toString(), start];
|
// const args = ['XAUTOCLAIM', key, group, consumer, minIdleTime.toString(), start];
|
||||||
|
|
||||||
if (options?.COUNT) {
|
// if (options?.COUNT) {
|
||||||
args.push('COUNT', options.COUNT.toString());
|
// args.push('COUNT', options.COUNT.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
type XAutoClaimRawReply = [RedisCommandArgument, Array<any>];
|
// type XAutoClaimRawReply = [RedisCommandArgument, Array<any>];
|
||||||
|
|
||||||
interface XAutoClaimReply {
|
// interface XAutoClaimReply {
|
||||||
nextId: RedisCommandArgument;
|
// nextId: RedisCommandArgument;
|
||||||
messages: StreamMessagesReply;
|
// messages: StreamMessagesReply;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: XAutoClaimRawReply): XAutoClaimReply {
|
// export function transformReply(reply: XAutoClaimRawReply): XAutoClaimReply {
|
||||||
return {
|
// return {
|
||||||
nextId: reply[0],
|
// nextId: reply[0],
|
||||||
messages: transformStreamMessagesReply(reply[1])
|
// messages: transformStreamMessagesReply(reply[1])
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||||
import { transformArguments as transformXAutoClaimArguments } from './XAUTOCLAIM';
|
// import { transformArguments as transformXAutoClaimArguments } from './XAUTOCLAIM';
|
||||||
|
|
||||||
export { FIRST_KEY_INDEX } from './XAUTOCLAIM';
|
// export { FIRST_KEY_INDEX } from './XAUTOCLAIM';
|
||||||
|
|
||||||
export function transformArguments(...args: Parameters<typeof transformXAutoClaimArguments>): RedisCommandArguments {
|
// export function transformArguments(...args: Parameters<typeof transformXAutoClaimArguments>): RedisCommandArguments {
|
||||||
return [
|
// return [
|
||||||
...transformXAutoClaimArguments(...args),
|
// ...transformXAutoClaimArguments(...args),
|
||||||
'JUSTID'
|
// 'JUSTID'
|
||||||
];
|
// ];
|
||||||
}
|
// }
|
||||||
|
|
||||||
type XAutoClaimJustIdRawReply = [RedisCommandArgument, Array<RedisCommandArgument>];
|
// type XAutoClaimJustIdRawReply = [RedisCommandArgument, Array<RedisCommandArgument>];
|
||||||
|
|
||||||
interface XAutoClaimJustIdReply {
|
// interface XAutoClaimJustIdReply {
|
||||||
nextId: RedisCommandArgument;
|
// nextId: RedisCommandArgument;
|
||||||
messages: Array<RedisCommandArgument>;
|
// messages: Array<RedisCommandArgument>;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function transformReply(reply: XAutoClaimJustIdRawReply): XAutoClaimJustIdReply {
|
// export function transformReply(reply: XAutoClaimJustIdRawReply): XAutoClaimJustIdReply {
|
||||||
return {
|
// return {
|
||||||
nextId: reply[0],
|
// nextId: reply[0],
|
||||||
messages: reply[1]
|
// messages: reply[1]
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user