From 9f64c56e0f6994df0609a803e613a055ee57a7cd Mon Sep 17 00:00:00 2001 From: Chayim Date: Wed, 1 Sep 2021 11:44:59 +0300 Subject: bgsave schedule support (#1555) bgsave tests Part of #1546 --- redis/commands.py | 7 +++++-- tests/test_commands.py | 5 +++++ 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 -- cgit v1.2.1