Skip to content

bgsave schedule support #1555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions redis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,15 @@ def bgrewriteaof(self):
"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)"
Expand Down
5 changes: 5 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,11 @@ def test_time(self, r):
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
Expand Down