-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add local cache stats in the integration test
- Loading branch information
Junchao Lyu
committed
Jan 15, 2020
1 parent
3ec0f5f
commit c0d1f48
Showing
6 changed files
with
263 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package redis | ||
|
||
import ( | ||
"github.com/coocood/freecache" | ||
stats "github.com/lyft/gostats" | ||
) | ||
|
||
type localCacheStats struct { | ||
cache *freecache.Cache | ||
evacuateCount stats.Gauge | ||
expiredCount stats.Gauge | ||
entryCount stats.Gauge | ||
averageAccessTime stats.Gauge | ||
hitCount stats.Gauge | ||
missCount stats.Gauge | ||
lookupCount stats.Gauge | ||
overwriteCount stats.Gauge | ||
} | ||
|
||
func NewLocalCacheStats(localCache *freecache.Cache, scope stats.Scope) stats.StatGenerator { | ||
return localCacheStats{ | ||
cache: localCache, | ||
evacuateCount: scope.NewGauge("evacuateCount"), | ||
expiredCount: scope.NewGauge("expiredCount"), | ||
entryCount: scope.NewGauge("entryCount"), | ||
averageAccessTime: scope.NewGauge("averageAccessTime"), | ||
hitCount: scope.NewGauge("hitCount"), | ||
missCount: scope.NewGauge("missCount"), | ||
lookupCount: scope.NewGauge("lookupCount"), | ||
overwriteCount: scope.NewGauge("overwriteCount"), | ||
} | ||
} | ||
|
||
func (stats localCacheStats) GenerateStats() { | ||
stats.evacuateCount.Set(uint64(stats.cache.EvacuateCount())) | ||
stats.expiredCount.Set(uint64(stats.cache.ExpiredCount())) | ||
stats.entryCount.Set(uint64(stats.cache.EntryCount())) | ||
stats.averageAccessTime.Set(uint64(stats.cache.AverageAccessTime())) | ||
stats.hitCount.Set(uint64(stats.cache.HitCount())) | ||
stats.missCount.Set(uint64(stats.cache.MissCount())) | ||
stats.lookupCount.Set(uint64(stats.cache.LookupCount())) | ||
stats.overwriteCount.Set(uint64(stats.cache.OverwriteCount())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.