AverageAccessTime returns the average unix timestamp when a entry being accessed. Entries have greater access time will be evacuated when it is about to be overwritten by new value.
()
| 357 | // Entries have greater access time will be evacuated when it |
| 358 | // is about to be overwritten by new value. |
| 359 | func (cache *Cache) AverageAccessTime() int64 { |
| 360 | var entryCount, totalTime int64 |
| 361 | for i := range cache.segments { |
| 362 | totalTime += atomic.LoadInt64(&cache.segments[i].totalTime) |
| 363 | entryCount += atomic.LoadInt64(&cache.segments[i].totalCount) |
| 364 | } |
| 365 | if entryCount == 0 { |
| 366 | return 0 |
| 367 | } else { |
| 368 | return totalTime / entryCount |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | // HitCount is a metric that returns number of times a key was found in the cache. |
| 373 | func (cache *Cache) HitCount() (count int64) { |
no outgoing calls