mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-15 12:34:44 +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"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/micro/micro/v3/service/logger"
|
||||||
"github.com/hashicorp/golang-lru"
|
"github.com/hashicorp/golang-lru"
|
||||||
"github.com/micro/micro/v3/service/store"
|
"github.com/micro/micro/v3/service/store"
|
||||||
"github.com/micro/services/pkg/tenant"
|
"github.com/micro/services/pkg/tenant"
|
||||||
@@ -88,19 +89,17 @@ func (c *cache) Get(key string, val interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// otherwise unmarshal and return it
|
// otherwise unmarshal and return it
|
||||||
if err := json.Unmarshal(i.val, val); err != nil {
|
return json.Unmarshal(i.val, val)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Infof("Cache miss for %v", k)
|
||||||
|
|
||||||
// otherwise check the store
|
// otherwise check the store
|
||||||
if c.Store == nil {
|
if c.Store == nil {
|
||||||
c.Store = store.DefaultStore
|
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 {
|
if err != nil && err == store.ErrNotFound {
|
||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user