summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-09-01 11:44:59 +0300
committerGitHub <noreply@github.com>2021-09-01 11:44:59 +0300
commit9f64c56e0f6994df0609a803e613a055ee57a7cd (patch)
tree4df1c0274f58da34dc0f5f9dbc5af3a7146ddd62
parent18c1cc7482d2177809d381e91721f119117849ff (diff)
downloadredis-py-9f64c56e0f6994df0609a803e613a055ee57a7cd.tar.gz
bgsave schedule support (#1555)
bgsave tests Part of #1546
-rw-r--r--redis/commands.py7
-rw-r--r--tests/test_commands.py5
2 files changed, 10 insertions, 2 deletions
diff --git a/redis/commands.py b/redis/commands.py
index 7066bd8..e1f7368 100644
--- a/redis/commands.py
+++ b/redis/commands.py
@@ -268,12 +268,15 @@ class Commands:
"Tell the Redis server to rewrite the AOF file from data in memory."
return self.execute_command('BGREWRITEAOF')
- def bgsave(self):
+ def bgsave(self, schedule=True):
"""
Tell the Redis server to save its data to disk. Unlike save(),
this method is asynchronous and returns immediately.
"""
- return self.execute_command('BGSAVE')
+ pieces = []
+ if schedule:
+ pieces.append("SCHEDULE")
+ return self.execute_command('BGSAVE', *pieces)
def client_kill(self, address):
"Disconnects the client at ``address`` (ip:port)"
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 5a5e8f3..1a34712 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -547,6 +547,11 @@ class TestRedisCommands:
assert isinstance(t[0], int)
assert isinstance(t[1], int)
+ def test_bgsave(self, r):
+ assert r.bgsave()
+ time.sleep(0.3)
+ assert r.bgsave(True)
+
# BASIC KEY COMMANDS
def test_append(self, r):
assert r.append('a', 'a1') == 2