mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Adding metrics to cache for profile by ids api (#4925)
This commit is contained in:
committed by
enahum
parent
4bca74d5c1
commit
96b4e0ed87
@@ -25,6 +25,9 @@ type MetricsInterface interface {
|
||||
|
||||
IncrementMemCacheHitCounter(cacheName string)
|
||||
IncrementMemCacheMissCounter(cacheName string)
|
||||
|
||||
AddMemCacheHitCounter(cacheName string, amount float64)
|
||||
AddMemCacheMissCounter(cacheName string, amount float64)
|
||||
}
|
||||
|
||||
var theMetricsInterface MetricsInterface
|
||||
|
||||
@@ -804,6 +804,7 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool) St
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
metrics := einterfaces.GetMetricsInterface()
|
||||
|
||||
var users []*model.User
|
||||
userMap := make(map[string]*model.User)
|
||||
@@ -820,8 +821,15 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool) St
|
||||
remainingUserIds = append(remainingUserIds, userId)
|
||||
}
|
||||
}
|
||||
if metrics != nil {
|
||||
metrics.AddMemCacheHitCounter("Profile By Ids", float64(len(userMap)))
|
||||
metrics.AddMemCacheMissCounter("Profile By Ids", float64(len(remainingUserIds)))
|
||||
}
|
||||
} else {
|
||||
remainingUserIds = userIds
|
||||
if metrics != nil {
|
||||
metrics.AddMemCacheMissCounter("Profile By Ids", float64(len(remainingUserIds)))
|
||||
}
|
||||
}
|
||||
|
||||
// If everything came from the cache then just return
|
||||
|
||||
Reference in New Issue
Block a user