-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
* mget leads to crossslot keys don't hash to the same slot #110
Conversation
monitor/redis/watcher.go
Outdated
if err != nil { | ||
log.Errorf("failed to MGET keys %v: %v", w.keys, err) | ||
return | ||
values := make([]interface{}, len(w.keys)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be safe to use []string
here because Get(...).Result()
returns a string. It would reduce the complexity and prevent from casting to interface{}
and then again to string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at most []*string
because we use nil
to signal a bad retrieval
func (w *Watcher) getValues(ctx context.Context, ch chan<- []*change.Change) { | ||
values, err := w.client.MGet(ctx, w.keys...).Result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted keys would get nil
values as you can see from the lib unit tests:
https://github.com/go-redis/redis/blob/master/commands_test.go#L1165-L1173
It means that deletion operations would not be pickedup by the service.
monitor/redis/watcher.go
Outdated
} | ||
// notice: if the key is not found we default to the same behavior as if | ||
// the key was found with an empty value string | ||
if strCmd.Err() != nil && strCmd.Err() != redis.Nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can now trigger update to ""
in case the key was deleted generating consistency across pods
f2a0c4b
to
65363c0
Compare
monitor/redis/watcher.go
Outdated
@@ -70,20 +70,35 @@ func (w *Watcher) monitor(ctx context.Context, ch chan<- []*change.Change) { | |||
} | |||
} | |||
|
|||
func toPtr(s string) *string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we inline this? it is only used in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Which problem is this PR solving?
#111
#113
Short description of the changes