From bdfb1d3d4dbe3b34f974cbc3fecb6fa4b9f8d01c Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 19 May 2021 15:02:22 +0100 Subject: [PATCH] add logging to cache --- pkg/cache/cache.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 487eadc..69a3cc6 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -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 {