Skip to content
Open
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
8 changes: 4 additions & 4 deletions pyredis/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def log_command(self, command: Array) -> None:
class AppendOnlyFilePersistence(RedisPersistence):
def __init__(self, filename: str):
self._filename = filename
self.file = open(filename, mode="ab", buffering=0)

def log_command(self, command: Array) -> None:
self.file.write(f"*{len(command)}\r\n".encode())
with open(self._filename, mode="ab", buffering=0) as file:
file.write(f"*{len(command)}\r\n".encode())

for item in command:
self.file.write(item.resp_encode())
for item in command:
file.write(item.resp_encode())


class NoPersistence(RedisPersistence):
Expand Down