From 18965b4c5459388552b407b094dcf20fd9d3e31c Mon Sep 17 00:00:00 2001 From: Shawn Poulson Date: Wed, 26 Jun 2024 17:00:27 -0400 Subject: [PATCH] Logging. --- groupcache.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/groupcache.go b/groupcache.go index 75812b5..ecc66e9 100644 --- a/groupcache.go +++ b/groupcache.go @@ -28,6 +28,7 @@ import ( "context" "errors" "strconv" + "strings" "sync" "sync/atomic" "time" @@ -297,6 +298,16 @@ func (g *Group) Set(ctx context.Context, key string, value []byte, expire time.T func (g *Group) Remove(ctx context.Context, key string) error { g.peersOnce.Do(g.initPeers) + var peerList []string + for _, peer := range g.peers.GetAll() { + peerList = append(peerList, peer.GetURL()) + } + logrus.WithFields(logrus.Fields{ + "name": g.name, + "peers": strings.Join(peerList, ","), + "key": key, + }).Info("Group.Remove()") + _, err := g.removeGroup.Do(key, func() (interface{}, error) { // Remove from key owner first owner, ok := g.peers.PickPeer(key)