From 9d5462ca04457cf8f24b0533331ac06091530356 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 28 Oct 2016 12:55:56 -0400 Subject: [PATCH] Don't cache physical responses when thre was an error (#2040) --- physical/cache.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/physical/cache.go b/physical/cache.go index b184fbcee..d10ddd960 100644 --- a/physical/cache.go +++ b/physical/cache.go @@ -45,7 +45,9 @@ func (c *Cache) Purge() { func (c *Cache) Put(entry *Entry) error { err := c.backend.Put(entry) - c.lru.Add(entry.Key, entry) + if err == nil { + c.lru.Add(entry.Key, entry) + } return err } @@ -78,7 +80,9 @@ func (c *Cache) Get(key string) (*Entry, error) { func (c *Cache) Delete(key string) error { err := c.backend.Delete(key) - c.lru.Remove(key) + if err == nil { + c.lru.Remove(key) + } return err }