-
Notifications
You must be signed in to change notification settings - Fork 22
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
Feat MGet #5
Feat MGet #5
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5 +/- ##
==========================================
+ Coverage 90.08% 90.37% +0.29%
==========================================
Files 3 3
Lines 474 582 +108
==========================================
+ Hits 427 526 +99
- Misses 35 41 +6
- Partials 12 15 +3 ☔ View full report in Codecov by Sentry. |
val, err := strCmd.Result() | ||
if err != nil && !errors.Is(err, r.Nil()) { | ||
logger.Error("MGet#strCmd(%s) error(%v)", keyIdxMap[idx], err) | ||
} else if len(val) > 0 { |
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.
万一是空呢,而不是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.
Pipeline模式下返回结果,当key不存在,返回的val就是空(""),而不是err=redis.Nil。所以,这里如果val="",作miss处理(但下次查不会穿透)。因此,业务上设置key的value="",在MGet场景该key会miss。
remote/goredisv8adapter.go
Outdated
func (r *GoRedisV8Adaptor) MGet(ctx context.Context, keys ...string) (map[string]any, error) { | ||
pipeline := r.client.Pipeline() | ||
keyIdxMap := make(map[int]string, len(keys)) | ||
ret := make(map[string]any) |
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.
对于这种sdk,最好赋值cap
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.
OK,统一加上,避免扩容。
cache.go
Outdated
c.statsHandler.IncrQueryFail(err) | ||
logger.Error("MGet#fn(%s) error(%v)", util.JoinAny(",", ids), err) | ||
} else { | ||
placeholderValues := make(map[string]any) |
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.
设置下cap?
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.
OK,统一加上,避免扩容。
Motivation:
We need to support the function of batch ID querying cache entities. Golang's generics can support this function very conveniently.