Skip to content

Commit

Permalink
Check every memcached when delete a key
Browse files Browse the repository at this point in the history
  • Loading branch information
manegron committed Jul 11, 2024
1 parent 7efa852 commit 12ba92d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,25 @@ func main() {
if created {
// Delete the key from Memcached if the incident was created successfully
err = mc.Delete(key)

if err != nil {
log.Printf("Error deleting key %s: %v", key, err)
if err == memcache.ErrCacheMiss {
// If cache miss, check all servers for the key
for _, server := range config.MemcachedServers {
mcSingle := memcache.New(server)
err = mcSingle.Delete(key)
if err == nil {
log.Printf("Successfully deleted key %s after creating incident", key)
break
} else if err != memcache.ErrCacheMiss {
log.Printf("Error getting key %s from server %s: %v", key, server, err)
}
}
}
if err != nil {
log.Printf("Error deleting key %s: %v", key, err)
continue
}
} else {
log.Printf("Successfully deleted key %s after creating incident", key)
}
Expand Down

0 comments on commit 12ba92d

Please sign in to comment.