dice icon indicating copy to clipboard operation
dice copied to clipboard

Adding support for `HGET.WATCH` cmd

Open ganimtron-10 opened this issue 8 months ago • 3 comments

Fixes #1631

ganimtron-10 avatar Mar 23 '25 21:03 ganimtron-10

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 23 '25 21:03 CLAassistant

@ganimtron-10 i was working on this too and my code is literally the same(although i didnt write tests). However when i was testing it, it watches expected field correctly, but also prints a fingerprint for a field it is not watching. I don't believe this was expected, as i referred the docs for GET.WATCH. I ran your code, obviously resulting in the same ambiguity. @arpitbbhayani it would be great if you clarify :) P.S : newbie and first time contributor here, excuse me if I missed something obvious and would love to complete the implementation, if neccessary

meethereum avatar Mar 23 '25 21:03 meethereum

Hi @meethereum ,

Yes I also saw this while testing, after digging a bit deeper I found this is due to the NotifyWatchers in the watch_manager.go, which notifies the clients depending on the key <--> fingerprint basis and as we can have same keys for different fields it gets triggered.

One approach I can think of is

Update the key <--> fingerprint relation, to use a keyGenerator func which would spit out uniquely formatted keys depending on cmds (eg. cmd -> genKey: get k1 -> k1, hget k1 f1 -> k1f1, hget k1 f2 -> k1f2)

not sure if its ideal or not, will wait for maintainers to comment

ganimtron-10 avatar Mar 24 '25 05:03 ganimtron-10

Thanks for the patch.

arpitbbhayani avatar Mar 25 '25 11:03 arpitbbhayani