From f37541abb72fa34ac5a65c5146b0bd49d06465bf Mon Sep 17 00:00:00 2001 From: Matt Gleich Date: Sat, 27 Jul 2024 00:58:48 -0400 Subject: [PATCH] feat: check for change in cache data by comparing json data Signed-off-by: Matt Gleich --- pkg/cache/cache.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 212e48d..19a8ba3 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -5,7 +5,6 @@ import ( "fmt" "net/http" "path/filepath" - "reflect" "sync" "time" @@ -71,12 +70,12 @@ func (c *Cache[T]) Route() http.HandlerFunc { func (c *Cache[T]) Update(data T) { var updated bool c.mutex.Lock() - if !reflect.DeepEqual(data, c.data) { - lumber.Debug("caches are not the same for", c.Name) - old, _ := json.Marshal(c.data) - lumber.Debug("old cache:", string(old)) - new, _ := json.Marshal(data) - lumber.Debug("new cache:", string(new)) + lumber.Debug(c.Name) + old, _ := json.Marshal(c.data) + lumber.Debug("old cache:", string(old)) + new, _ := json.Marshal(data) + lumber.Debug("new cache:", string(new)) + if string(old) != string(new) { c.data = data c.updated = time.Now() updated = true