hit/miss debug

This commit is contained in:
Umputun
2018-01-08 01:31:24 -06:00
parent f992d9c578
commit b9ba52b2a1
+3
View File
@@ -1,6 +1,7 @@
package rest
import (
"log"
"time"
cache "github.com/patrickmn/go-cache"
@@ -16,9 +17,11 @@ func newLoadingCache(defaultExpiration, cleanupInterval time.Duration) *loadingC
func (lc *loadingCache) get(key string, ttl time.Duration, fn func() ([]byte, error)) (data []byte, err error) {
if b, ok := lc.bytesCache.Get(key); ok {
log.Printf("[DEBUG] cache hit %s", key)
return b.([]byte), nil
}
log.Printf("[DEBUG] cache miss %s", key)
if data, err = fn(); err != nil {
return data, err
}