go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

Support for tracking.

Open luboszk opened this issue 4 years ago • 7 comments

Hi,

I'm checking currently that library to use it in the project which I'm working on. As part of that, I need to use client-side caching which uses tracking. Link to the Redis: documentation

Can anyone tell me if it's possible to right now use that feature or there are still some parts missing? I was not able to find any documentation/code about tracking so I assume support for that does not exist at all. If anyone could point me into the direction of how it should be implemented I can work on that.

Regards, Lubosz.

luboszk avatar Jan 24 '20 19:01 luboszk

does anyone try to work on this ,or can i work on this?

fighterlyt avatar Dec 02 '20 11:12 fighterlyt

@fighterlyt AFAIK none is working on this. And I still did not get any experience with client side caching in Redis.

vmihailenco avatar Dec 02 '20 13:12 vmihailenco

Hi, Are there any plans to support this? Thanks,

bdollma avatar Apr 19 '22 19:04 bdollma

I've been curious to implement this, I'm thinking of using the approach where you redirect all your invalidations to a pubsub channel: https://redis.io/docs/manual/client-side-caching/#two-connections-mode (I was thinking of using this approach instead of pushing the invalidation on the same connection to avoid breaking the requests/response model ingrained in the source code of the library)

The problem is that for every connection in the pool you need to execute the client tracking command and to redirect invalidations to specific client id. The pool module offers no "run this for every connection" and while I can run it for idle connections I am not sure how to handle some connection being busy etc without the logic becoming unmanageable. Then you also need to handle reconnects etc.

gabzim avatar Aug 06 '22 21:08 gabzim

@gabzim I was also working on how to integrate go-redis with Redis client side caching. However I also feel it's quite awkward to manage connection IDs. My workaround is that I publish invalidation messages to a normal Redis pubsub channel, and subscribe to the channel in a separate groroutine.

minghsu0107 avatar Aug 15 '22 06:08 minghsu0107

I was curious about using this redis feature so I decided to have a go at creating a POC myself if anyone is interested. I used the approach mentioned above with a subscription and, as pointed out, getting the client ID of a redis.PubSub is a bit awkward.

Implemented for a redis.Ring, but I'm sure similar approaches could be used for a plain redis.Client or redis.ClusterClient.

https://gist.github.com/matyat/5738dcf323aa17a73ed333e73523198e

matyat avatar Feb 27 '23 09:02 matyat

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Feb 28 '24 00:02 github-actions[bot]