mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
add logging to cache
This commit is contained in:
11
pkg/cache/cache.go
vendored
11
pkg/cache/cache.go
vendored
@@ -9,6 +9,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
"github.com/micro/micro/v3/service/store"
|
||||
"github.com/micro/services/pkg/tenant"
|
||||
@@ -88,19 +89,17 @@ func (c *cache) Get(key string, val interface{}) error {
|
||||
}
|
||||
|
||||
// otherwise unmarshal and return it
|
||||
if err := json.Unmarshal(i.val, val); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return json.Unmarshal(i.val, val)
|
||||
}
|
||||
|
||||
logger.Infof("Cache miss for %v", k)
|
||||
|
||||
// otherwise check the store
|
||||
if c.Store == nil {
|
||||
c.Store = store.DefaultStore
|
||||
}
|
||||
|
||||
recs, err := c.Store.Read(c.Key(key), store.ReadLimit(1))
|
||||
recs, err := c.Store.Read(k, store.ReadLimit(1))
|
||||
if err != nil && err == store.ErrNotFound {
|
||||
return ErrNotFound
|
||||
} else if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user