Skip to content

feat: support client cache with libvalkey #189

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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: 8 additions & 0 deletions valkey/_parsers/libvalkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, socket_read_size):
raise ValkeyError("libvalkey is not installed")
self.socket_read_size = socket_read_size
self._buffer = bytearray(socket_read_size)
self.invalidations_push_handler_func = None

def __del__(self):
try:
Expand Down Expand Up @@ -144,6 +145,9 @@ def read_response(self, disable_decoding=False):
raise response[0]
return response

def set_invalidation_push_handler(self, invalidations_push_handler_func):
self.invalidations_push_handler_func = invalidations_push_handler_func


class _AsyncLibvalkeyParser(AsyncBaseParser):
"""Async implementation of parser class for connections using libvalkey"""
Expand All @@ -155,6 +159,7 @@ def __init__(self, socket_read_size: int):
raise ValkeyError("libvalkey is not available.")
super().__init__(socket_read_size=socket_read_size)
self._reader = None
self.invalidations_push_handler_func = None

def on_connect(self, connection):
import libvalkey
Expand Down Expand Up @@ -228,3 +233,6 @@ async def read_response(
):
raise response[0]
return response

def set_invalidation_push_handler(self, invalidations_push_handler_func):
self.invalidations_push_handler_func = invalidations_push_handler_func