diff --git a/packages/public-api/src/apis/redis/RedisClient.ts b/packages/public-api/src/apis/redis/RedisClient.ts index 9f819fca..8ac6f2fc 100644 --- a/packages/public-api/src/apis/redis/RedisClient.ts +++ b/packages/public-api/src/apis/redis/RedisClient.ts @@ -354,6 +354,18 @@ export class TxClient implements TxClientLike { return this; } + async hsetnx(key: string, field: string, value: string): Promise { + return this.hSetNX(key, field, value); + } + + async hSetNX(key: string, field: string, value: string): Promise { + await this.#storage.HSetNX( + { key, field, value, transactionId: this.#transactionId }, + this.#metadata + ); + return this; + } + async hincrby(key: string, field: string, value: number): Promise { return this.hIncrBy(key, field, value); } diff --git a/packages/redis/src/RedisClient.ts b/packages/redis/src/RedisClient.ts index 38463d45..5b93a37b 100644 --- a/packages/redis/src/RedisClient.ts +++ b/packages/redis/src/RedisClient.ts @@ -314,6 +314,14 @@ export class TxClient implements TxClientLike { return this; } + async hSetNX(key: string, field: string, value: string): Promise { + await this.#plugin.HSetNX( + { key, field, value, transactionId: this.#transactionId }, + this.#metadata + ); + return this; + } + async hIncrBy(key: string, field: string, value: number): Promise { await this.#plugin.HIncrBy( { key, field, value, transactionId: this.#transactionId }, diff --git a/packages/redis/src/types/redis.ts b/packages/redis/src/types/redis.ts index 8068f5db..8e2d4d89 100644 --- a/packages/redis/src/types/redis.ts +++ b/packages/redis/src/types/redis.ts @@ -573,8 +573,9 @@ export type TxClientLike = { * console.log("Number of fields added: " + numFieldsAdded); * } * ``` - */ + */ hSet(key: string, fieldValues: { [field: string]: string }): Promise; + hSetNX(key: string, field: string, value: string): Promise; /** * Returns the value associated with field in the hash stored at key. * https://redis.io/commands/hget