更新 cache/cache.go
This commit is contained in:
5
cache/cache.go
vendored
5
cache/cache.go
vendored
@@ -36,6 +36,11 @@ func NewMemoryCache(maxSize int64, ttl time.Duration) *MemoryCache {
|
||||
return mc
|
||||
}
|
||||
|
||||
func (e *CacheEntry) Age() string {
|
||||
age := time.Since(e.Timestamp)
|
||||
return strconv.FormatInt(int64(age.Seconds()), 10)
|
||||
}
|
||||
|
||||
func (mc *MemoryCache) Get(key string) (*CacheEntry, bool) {
|
||||
val, ok := mc.entries.Load(key)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user