dice
dice copied to clipboard
Adding support for `HGET.WATCH` cmd
Fixes #1631
@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
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
Thanks for the patch.