Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/public-api/src/apis/redis/RedisClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ export class TxClient implements TxClientLike {
return this;
}

async hsetnx(key: string, field: string, value: string): Promise<TxClientLike> {
return this.hSetNX(key, field, value);
}

async hSetNX(key: string, field: string, value: string): Promise<TxClientLike> {
await this.#storage.HSetNX(
{ key, field, value, transactionId: this.#transactionId },
this.#metadata
);
return this;
}

async hincrby(key: string, field: string, value: number): Promise<TxClientLike> {
return this.hIncrBy(key, field, value);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/redis/src/RedisClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ export class TxClient implements TxClientLike {
return this;
}

async hSetNX(key: string, field: string, value: string): Promise<TxClientLike> {
await this.#plugin.HSetNX(
{ key, field, value, transactionId: this.#transactionId },
this.#metadata
);
return this;
}

async hIncrBy(key: string, field: string, value: number): Promise<TxClientLike> {
await this.#plugin.HIncrBy(
{ key, field, value, transactionId: this.#transactionId },
Expand Down
3 changes: 2 additions & 1 deletion packages/redis/src/types/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,9 @@ export type TxClientLike = {
* console.log("Number of fields added: " + numFieldsAdded);
* }
* ```
*/
*/
hSet(key: string, fieldValues: { [field: string]: string }): Promise<TxClientLike>;
hSetNX(key: string, field: string, value: string): Promise<TxClientLike>;
/**
* Returns the value associated with field in the hash stored at key.
* https://redis.io/commands/hget
Expand Down