File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -865,11 +865,24 @@ XRANGE somestream - +
865865 ) : Promise < Integer > ;
866866
867867 // Client
868+ /**
869+ * Returns the name of the current connection which can be set by `client_setname`.
870+ * @see https://redis.io/commands/client-getname
871+ */
872+ client_getname ( ) : Promise < Bulk > ;
873+
868874 /**
869875 * Returns the id of the current redis connection.
870876 */
871877 client_id ( ) : Promise < Integer > ;
872878
879+ /**
880+ * Sets a `connectionName` to the current connection.
881+ * You can get the name of the current connection using `client_getname()`.
882+ * @see https://redis.io/commands/client-setname
883+ */
884+ client_setname ( connectionName : string ) : Promise < Status > ;
885+
873886 // Cluster
874887 cluster_addslots ( ...slots : number [ ] ) : Promise < Status > ;
875888 cluster_countfailurereports ( node_id : string ) : Promise < Integer > ;
Original file line number Diff line number Diff line change @@ -283,10 +283,18 @@ export class RedisImpl implements Redis {
283283 > ;
284284 }
285285
286+ client_getname ( ) {
287+ return this . execBulkReply ( "CLIENT" , "GETNAME" ) ;
288+ }
289+
286290 client_id ( ) {
287291 return this . execIntegerReply ( "CLIENT" , "ID" ) ;
288292 }
289293
294+ client_setname ( connectionName : string ) {
295+ return this . execStatusReply ( "CLIENT" , "SETNAME" , connectionName ) ;
296+ }
297+
290298 cluster_addslots ( ...slots : number [ ] ) {
291299 return this . execStatusReply ( "CLUSTER" , "ADDSLOTS" , ...slots ) ;
292300 }
Original file line number Diff line number Diff line change @@ -42,4 +42,9 @@ suite.test("client id", async () => {
4242 assertEquals ( typeof id , "number" ) ;
4343} ) ;
4444
45+ suite . test ( "client setname & getname" , async ( ) => {
46+ assertEquals ( await client . client_setname ( "deno-redis" ) , "OK" ) ;
47+ assertEquals ( await client . client_getname ( ) , "deno-redis" ) ;
48+ } ) ;
49+
4550suite . runTests ( ) ;
You can’t perform that action at this time.
0 commit comments