Skip to content

Commit 3c24284

Browse files
committed
bgsave schedule support
bgsave tests Part of redis#1546
1 parent efdba1a commit 3c24284

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

redis/commands.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,15 @@ def bgrewriteaof(self):
268268
"Tell the Redis server to rewrite the AOF file from data in memory."
269269
return self.execute_command('BGREWRITEAOF')
270270

271-
def bgsave(self):
271+
def bgsave(self, schedule=True):
272272
"""
273273
Tell the Redis server to save its data to disk. Unlike save(),
274274
this method is asynchronous and returns immediately.
275275
"""
276-
return self.execute_command('BGSAVE')
276+
pieces = []
277+
if schedule:
278+
pieces.append("SCHEDULE")
279+
return self.execute_command('BGSAVE', *pieces)
277280

278281
def client_kill(self, address):
279282
"Disconnects the client at ``address`` (ip:port)"

tests/test_commands.py

+5
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ def test_time(self, r):
547547
assert isinstance(t[0], int)
548548
assert isinstance(t[1], int)
549549

550+
def test_bgsave(self, r):
551+
assert r.bgsave()
552+
time.sleep(0.3)
553+
assert r.bgsave(True)
554+
550555
# BASIC KEY COMMANDS
551556
def test_append(self, r):
552557
assert r.append('a', 'a1') == 2

0 commit comments

Comments
 (0)