2881099 / FreeRedis

🦄 FreeRedis is .NET40+ redis client. supports cluster, sentinel, master-slave, pub-sub, lua, pipeline, transaction, streams, client-side-caching, and pooling.
MIT License
920 stars 164 forks source link

RESP3 doesn't work well with server assisted client caching #178

Open killwort opened 8 months ago

killwort commented 8 months ago

When using RESP3 protocol RedisClient does not receive invalidation messages. That breaks client side caching completely. However, PubSub functionality works well with RESP3, so I suspect that client side cache subscribes wrong connection to the invalidations. To reproduce you may use your net8_clietn example with just adding RESP3 to connection string. The program will not receive invalidation messages as it does in RESP2(default) mode.

2881099 commented 7 months ago

see https://redis.io/docs/manual/client-side-caching/

When RESP3 is used instead, invalidation messages are sent (either in the same connection, or in the secondary connection when redirection is used) as push messages (read the RESP3 specification for more information).

The document does not have a demonstration of RESP3.

killwort commented 7 months ago

https://github.com/TheUniversalCity/RedisClient this library implements server assisted caching on top of RESP3, so it is practically possible (however it has its own problems, like lack of SSL support and bad fault tolerance). The socket in RESP3 mode is only connected once and used in full duplex mode.

2881099 commented 7 months ago

Invalidation messages are sent in the same connection (only available when the RESP3 protocol is used) or redirected in a different connection (available also with RESP2 and Pub/Sub).

From the description, RESP2 is more suitable for Invalidation messages.

RESP2 dual connection, using Client Tracking on REDIRECT ID, only needs to subscribe once to " redis: validate".