mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 10:06:14 +00:00
fix(flashnode): fix low performance due to traversing keys in fetch status.
close:#22838790 Signed-off-by: shuqiang-zheng <zhengshuqiang@oppo.com>
This commit is contained in:
parent
cf338f6fa5
commit
1cfd66ec91
@ -307,6 +307,11 @@ func (c *CacheEngine) Status() *proto.CacheStatus {
|
||||
return stat
|
||||
}
|
||||
|
||||
func (c *CacheEngine) GetHitRate() float64 {
|
||||
hitRate := c.lruCache.GetHitRate()
|
||||
return math.Trunc(hitRate.HitRate*1e4+0.5) * 1e-4
|
||||
}
|
||||
|
||||
func (c *CacheEngine) EvictCacheByVolume(evictVol string) (failedKeys []interface{}) {
|
||||
stat := c.lruCache.Status()
|
||||
failedKeys = make([]interface{}, 0)
|
||||
|
||||
@ -33,6 +33,7 @@ type LruCache interface {
|
||||
EvictAll()
|
||||
Close() error
|
||||
Status() *Status
|
||||
GetHitRate() RateStat
|
||||
Len() int
|
||||
GetRateStat() RateStat
|
||||
}
|
||||
@ -147,6 +148,10 @@ func (c *fCache) Status() *Status {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *fCache) GetHitRate() RateStat {
|
||||
return *c.recent
|
||||
}
|
||||
|
||||
func GenerateRandTime(expiration time.Duration) time.Duration {
|
||||
if expiration <= 0 {
|
||||
return expiration
|
||||
|
||||
Loading…
Reference in New Issue
Block a user