Skip to content

Commit 94af8c8

Browse files
committed
just a hack for testing pass through
1 parent cfc2f8b commit 94af8c8

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/client/lib/RESP/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ export interface CacheInfo {
269269
}
270270

271271
export type Command = {
272+
name?: () => string;
272273
FIRST_KEY_INDEX?: number | ((this: void, ...args: Array<any>) => RedisArgument | undefined);
273274
IS_READ_ONLY?: boolean;
274275
/**

packages/client/lib/client/pool.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ export class RedisClientPool<
6363
RESP extends RespVersions = 2,
6464
TYPE_MAPPING extends TypeMapping = {}
6565
> extends EventEmitter {
66-
// TODO: for CSC will have to be modified, to directly call function on underlying chosen client
6766
static #createCommand(command: Command, resp: RespVersions) {
67+
// TODO: for CSC will have to be modified, to directly call function on underlying chosen client
68+
// this is .name() is just a hack for now.
69+
const name = command.name?.();
6870
const transformReply = getTransformReply(command, resp);
6971
return async function (this: ProxyPool, ...args: Array<unknown>) {
72+
if (name) {
73+
return this.execute((client => { return client[name](...args)}))
74+
}
75+
7076
const redisArgs = command.transformArguments(...args),
7177
reply = await this.sendCommand(redisArgs, this._commandOptions);
72-
return transformReply ?
78+
return transformReply ?
7379
transformReply(reply, redisArgs.preserve) :
7480
reply;
7581
};

packages/client/lib/commands/GET.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
22

33
export default {
4+
name: () => { return "GET" },
45
FIRST_KEY_INDEX: 1,
56
IS_READ_ONLY: true,
67
transformArguments(key: RedisArgument) {

0 commit comments

Comments
 (0)