Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #370 from cpwr/master
Browse files Browse the repository at this point in the history
Added async support for flushall() and flushdb() (resolves #364)
  • Loading branch information
popravich committed Jan 29, 2018
2 parents 8bd157e + 33c782a commit f9f18a5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions aioredis/commands/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,30 @@ def debug_segfault(self, key):
# won't test, this probably works
return self.execute(b'DEBUG', 'SEGFAULT') # pragma: no cover

def flushall(self):
"""Remove all keys from all databases."""
fut = self.execute(b'FLUSHALL')
def flushall(self, async_op=False):
"""
Remove all keys from all databases.
:param async_op: lets the entire dataset to be freed asynchronously. \
Defaults to False
"""
if async_op:
fut = self.execute(b'FLUSHALL', b'ASYNC')
else:
fut = self.execute(b'FLUSHALL')
return wait_ok(fut)

def flushdb(self):
"""Remove all keys from the current database."""
fut = self.execute('FLUSHDB')
def flushdb(self, async_op=False):
"""
Remove all keys from the current database.
:param async_op: lets a single database to be freed asynchronously. \
Defaults to False
"""
if async_op:
fut = self.execute(b'FLUSHDB', b'ASYNC')
else:
fut = self.execute(b'FLUSHDB')
return wait_ok(fut)

def info(self, section='default'):
Expand Down

0 comments on commit f9f18a5

Please sign in to comment.