summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItamar Haber <itamar@redislabs.com>2018-11-08 21:45:17 +0200
committerItamar Haber <itamar@redislabs.com>2018-11-08 21:45:17 +0200
commit653d4b4bd5296f852cb7772b5d6bddb542184f43 (patch)
tree839338f425321f06f33940855979e70b54e291ab
parentec7a61b35f4816e42897b90dedb17dd1ec43e378 (diff)
downloadredis-py-653d4b4bd5296f852cb7772b5d6bddb542184f43.tar.gz
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 <itamar@redislabs.com>
-rwxr-xr-xredis/client.py28
1 files 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"