Skip to content

Commit

Permalink
feat: check for change in cache data by comparing json data
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Jul 27, 2024
1 parent d4d7709 commit f37541a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"net/http"
"path/filepath"
"reflect"
"sync"
"time"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f37541a

Please sign in to comment.