Skip to content

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

@kevin-lee-dialpad

Description

@kevin-lee-dialpad

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions