Skip to content

Retrieving invalidation message in redis-py when client tracking is used #3087

New issue

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

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

Already on GitHub? # to your account

Closed
theyueli opened this issue Dec 23, 2023 · 4 comments
Closed
Labels

Comments

@theyueli
Copy link

theyueli commented Dec 23, 2023

hello,

I posted this question on Redis' discussion panel:
redis/redis#12880

and got no response.. trying to post the same question here as it is more relevant...

I've been trying to play with client tracking in redis-py, I'm using Redis-py 5.0.1 with a local build of the redis main branch.

I have the following testing code:

import redis
from redis import Redis

def our_func(message):
    print(message)

def test_client_tracking_resp_sync():
    client = redis.Redis(host='localhost', port=6379, protocol=3)
    client.ping()
    resp = client.client_tracking_on()
    resp = client.execute_command("GET FOO", push_handler_func=our_func)
    resp = client.execute_command("SET FOO 100", push_handler_func=our_func)
    print(resp)
    resp = client.execute_command("GET FOO", push_handler_func=our_func)
    print(resp)
    resp = client.execute_command("FLUSHDB")
    print(resp)

test_client_tracking_resp_sync()

I'm trying to follow the suggestion here:
https://redis-py.readthedocs.io/en/stable/resp3_features.html

But it seems I can't retrieve the invalidation message as the print statement always just prints out the command result only:

b 'OK'
b '100'
True

Did I miss anything here?

The same flow works well with correctly printed invalidation message on redis-cli.

@dvora-h
Copy link
Collaborator

dvora-h commented Dec 23, 2023

Hi @theyueli,
As of now I don't think it's possible.
but as you can see in #3038 and #3089 this is something we are working on now - to add client side caching to redis-py so when this work will be done you will can use this feature

@theyueli
Copy link
Author

thanks a lot for clarifying! please keep me posted and i will definitely be willing to test it when it is ready.

@dvora-h
Copy link
Collaborator

dvora-h commented Jan 14, 2024

@theyueli We released a beta versions (5.1.0b2 already released and 5.1.0b3 will come in the next 2 days) with client side caching support, your more than welcome to test it and you can feel completely free to bother me with any questions you have about it.

@dvora-h dvora-h closed this as completed Jan 14, 2024
@theyueli
Copy link
Author

@theyueli We released a beta versions (5.1.0b2 already released and 5.1.0b3 will come in the next 2 days) with client side caching support, your more than welcome to test it and you can feel completely free to bother me with any questions you have about it.

thank you @dvora-h ! I will give it a try soon, will keep you posted.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants