I’m testing Redis client-side caching using redis-cli.
Redis server version: 7.0.11
redis-cli version: 7.0.11
redis-cli 1 I started with the monitor command:
redis-cli monitor
In redis-cli 2 I run the snippet:
HELLO: 3
CLIENT TRACKING ON PREFIX test: BCAST NOLOOP;
SET test:1 "a"
GET test:1
GET test:1
In the redis-cli 1 (monitor) every get command is shown.
1687010819.444931 [0 127.0.0.1:56346] "CLIENT" "TRACKING" "ON" "PREFIX" "test:" "BCAST" "NOLOOP"
1687010843.136642 [0 127.0.0.1:56346] "SET" "test:1" "a"
1687010854.656921 [0 127.0.0.1:56346] "GET" "test:1"
1687010856.557103 [0 127.0.0.1:56346] "GET" "test:1"
I wasn’t expecting to see the second GET command on the monitor. As I understand it, the second get shouldn’t call the server, it should get the data from the redis-cli local cache.
Do I need to implement caching somehow? Does redi-cli not implement it? The Redis client for Ruby(redis-5.0.6) has the same behaviour, with or without hiredis(hiredis-client-0.14.1)
2
Answers
Yes, you need to implement the local cache part at client side. Normally, a client library should implement it.
However, AFAIK, both
redis-cli
andhiredis
do not implement this feature.https://github.com/redis/rueidis
This client supports client-side caching.