@@ -461,9 +461,11 @@ class StrictRedis(object):
461
461
string_keys_to_dict ('BGREWRITEAOF BGSAVE' , lambda r : True ),
462
462
{
463
463
'CLIENT GETNAME' : lambda r : r and nativestr (r ),
464
+ 'CLIENT ID' : int ,
464
465
'CLIENT KILL' : bool_ok ,
465
466
'CLIENT LIST' : parse_client_list ,
466
467
'CLIENT SETNAME' : bool_ok ,
468
+ 'CLIENT UNBLOCK' : lambda r : r and int (r ) == 1 or False ,
467
469
'CLUSTER ADDSLOTS' : bool_ok ,
468
470
'CLUSTER COUNT-FAILURE-REPORTS' : lambda x : int (x ),
469
471
'CLUSTER COUNTKEYSINSLOT' : lambda x : int (x ),
@@ -792,10 +794,26 @@ def client_getname(self):
792
794
"Returns the current connection name"
793
795
return self .execute_command ('CLIENT GETNAME' )
794
796
797
+ def client_id (self ):
798
+ "Returns the current connection id"
799
+ return self .execute_command ('CLIENT ID' )
800
+
795
801
def client_setname (self , name ):
796
802
"Sets the current connection name"
797
803
return self .execute_command ('CLIENT SETNAME' , name )
798
804
805
+ def client_unblock (self , client_id , error = False ):
806
+ """
807
+ Unblocks a connection by its client id.
808
+ If ``error`` is True, unblocks the client with a special error message.
809
+ If ``error`` is False (default), the client is unblocked using the
810
+ regular timeout mechanism.
811
+ """
812
+ args = ['CLIENT UNBLOCK' , int (client_id )]
813
+ if error :
814
+ args .append (Token .get_token ('ERROR' ))
815
+ return self .execute_command (* args )
816
+
799
817
def config_get (self , pattern = "*" ):
800
818
"Return a dictionary of configuration based on the ``pattern``"
801
819
return self .execute_command ('CONFIG GET' , pattern )
0 commit comments