summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2018-11-08 12:13:47 -0800
committerGitHub <noreply@github.com>2018-11-08 12:13:47 -0800
commite9d48c9b93b489519608b8a2c4a988d431022617 (patch)
treed3b89ba6ff23f50a1db0278d9dc90ef4fa2c1f5d
parentec7a61b35f4816e42897b90dedb17dd1ec43e378 (diff)
parent345519d5999dee6cfa028fe8b7b707757dcd23fd (diff)
downloadredis-py-e9d48c9b93b489519608b8a2c4a988d431022617.tar.gz
Merge pull request #1058 from itamarhaber/flush-async
Adds `sync` flag to flushdb and flushall
-rwxr-xr-xredis/client.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/redis/client.py b/redis/client.py
index aaa7433..d82078e 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, asynchronous=False):
+ """
+ Delete all keys in all databases on the current host.
+
+ ``asynchronous`` indicates whether the operation is
+ executed asynchronously by the server.
+ """
+ args = []
+ if not asynchronous:
+ 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, asynchronous=False):
+ """
+ Delete all keys in the current database.
+
+ ``asynchronous`` indicates whether the operation is
+ executed asynchronously by the server.
+ """
+ args = []
+ if not asynchronous:
+ args.append(Token.get_token('ASYNC'))
+ return self.execute_command('FLUSHDB', *args)
def swapdb(self, first, second):
"Swap two databases"