From 653d4b4bd5296f852cb7772b5d6bddb542184f43 Mon Sep 17 00:00:00 2001 From: Itamar Haber Date: Thu, 8 Nov 2018 21:45:17 +0200 Subject: Adds `sync` flag to flushdb and flushall Uses sync as async is a keyword. Defaults to Redis pre v4 behavior. Signed-off-by: Itamar Haber --- redis/client.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/redis/client.py b/redis/client.py index aaa7433..9b0086b 100755 --- a/redis/client.py +++ b/redis/client.py @@ -841,13 +841,29 @@ class StrictRedis(object): "Echo the string back from the server" return self.execute_command('ECHO', value) - def flushall(self): - "Delete all keys in all databases on the current host" - return self.execute_command('FLUSHALL') + def flushall(self, sync=True): + """ + Delete all keys in all databases on the current host. + + ``sync`` indicates whether the operation is executed + synchronously by the server. + """ + args = [] + if not sync: + args.append(Token.get_token('ASYNC')) + return self.execute_command('FLUSHALL', *args) - def flushdb(self): - "Delete all keys in the current database" - return self.execute_command('FLUSHDB') + def flushdb(self, sync=True): + """ + Delete all keys in the current database. + + ``sync`` indicates whether the operation is executed + synchronously by the server. + """ + args = [] + if not sync: + args.append(Token.get_token('ASYNC')) + return self.execute_command('FLUSHDB', *args) def swapdb(self, first, second): "Swap two databases" -- cgit v1.2.1 From 345519d5999dee6cfa028fe8b7b707757dcd23fd Mon Sep 17 00:00:00 2001 From: Itamar Haber Date: Thu, 8 Nov 2018 22:02:18 +0200 Subject: Renames sync to asynchronous Signed-off-by: Itamar Haber --- redis/client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/redis/client.py b/redis/client.py index 9b0086b..d82078e 100755 --- a/redis/client.py +++ b/redis/client.py @@ -841,27 +841,27 @@ class StrictRedis(object): "Echo the string back from the server" return self.execute_command('ECHO', value) - def flushall(self, sync=True): + def flushall(self, asynchronous=False): """ Delete all keys in all databases on the current host. - ``sync`` indicates whether the operation is executed - synchronously by the server. + ``asynchronous`` indicates whether the operation is + executed asynchronously by the server. """ args = [] - if not sync: + if not asynchronous: args.append(Token.get_token('ASYNC')) return self.execute_command('FLUSHALL', *args) - def flushdb(self, sync=True): + def flushdb(self, asynchronous=False): """ Delete all keys in the current database. - ``sync`` indicates whether the operation is executed - synchronously by the server. + ``asynchronous`` indicates whether the operation is + executed asynchronously by the server. """ args = [] - if not sync: + if not asynchronous: args.append(Token.get_token('ASYNC')) return self.execute_command('FLUSHDB', *args) -- cgit v1.2.1