mailgun/groupcache

Can you update key?

Opened this issue · 1 comments

Can you update a key's value directly? Or have to delete the key first, then set "key: new value"?

// Check if the key exists in the cache var value []byte err = h.Group.Get(nil, k, groupcache.AllocatingByteSliceSink(&value)) if err == nil { // Key exists in the cache, compare with the new value if !reflect.DeepEqual(value, v) { // Values are different, update the cache jsonValue, err := json.Marshal(v) if err != nil { return err } expireTime := time.Now().Add(time.Duration(h.cacheTTL) * time.Minute) err = h.Group.Set(context.Background(), k, jsonValue, expireTime, false) if err != nil { return err } } }