Skip to content

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

Closed
@theyueli

Description

@theyueli

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions