Skip to content

Bug in client-side caching support when handling hash READ operations that specify field(s) #3612

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
kevin-lee-dialpad opened this issue Apr 21, 2025 · 1 comment

Comments

@kevin-lee-dialpad
Copy link

there seems to be a bug in client-side caching support when handling hash READ operations that specify field(s), such as HGET and HMGET.

current implementation only stores redis_keys and not hash field names, so the cache entry is shared for different field combinations and end up returning the wrong value.

it's easy to reproduce:

import redis
from redis.cache import CacheConfig

url = 'xxx'
key = 'abcde'

r = redis.from_url(url, protocol=3, cache_config=CacheConfig())
r1 = redis.from_url(url)
r1.hset(key, mapping={'field1': 'aaa', 'field2': 'bbb'})

print(r.hget(key, 'field1'))  # prints 'aaa'
print(r.hget(key, 'field2'))  # should print 'bbb', but uses the cache entry created in previous line and prints 'aaa'
@petyaslavova
Copy link
Collaborator

Hi @kevin-lee-dialpad, thank you for pointing this out! We'll have a look at this.

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

No branches or pull requests

2 participants