Skip to content

Commit

Permalink
just a hack for testing pass through
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpotter committed Feb 1, 2024
1 parent cfc2f8b commit 94af8c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/client/lib/RESP/types.ts
Expand Up @@ -269,6 +269,7 @@ export interface CacheInfo {
}

export type Command = {
name?: () => string;
FIRST_KEY_INDEX?: number | ((this: void, ...args: Array<any>) => RedisArgument | undefined);
IS_READ_ONLY?: boolean;
/**
Expand Down
10 changes: 8 additions & 2 deletions packages/client/lib/client/pool.ts
Expand Up @@ -63,13 +63,19 @@ export class RedisClientPool<
RESP extends RespVersions = 2,
TYPE_MAPPING extends TypeMapping = {}
> extends EventEmitter {
// TODO: for CSC will have to be modified, to directly call function on underlying chosen client
static #createCommand(command: Command, resp: RespVersions) {
// TODO: for CSC will have to be modified, to directly call function on underlying chosen client
// this is .name() is just a hack for now.
const name = command.name?.();
const transformReply = getTransformReply(command, resp);
return async function (this: ProxyPool, ...args: Array<unknown>) {
if (name) {
return this.execute((client => { return client[name](...args)}))
}

const redisArgs = command.transformArguments(...args),
reply = await this.sendCommand(redisArgs, this._commandOptions);
return transformReply ?
return transformReply ?
transformReply(reply, redisArgs.preserve) :
reply;
};
Expand Down
1 change: 1 addition & 0 deletions packages/client/lib/commands/GET.ts
@@ -1,6 +1,7 @@
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';

export default {
name: () => { return "GET" },
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
transformArguments(key: RedisArgument) {
Expand Down

0 comments on commit 94af8c8

Please sign in to comment.