aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/cache/cache.go')
-rw-r--r--plugin/cache/cache.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go
index 5d9bd746b..85e7e1bb8 100644
--- a/plugin/cache/cache.go
+++ b/plugin/cache/cache.go
@@ -106,7 +106,7 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
duration = msgTTL
}
- if key != -1 {
+ if key != -1 && duration > 0 {
w.set(res, key, mt, duration)
cacheSize.WithLabelValues(Success).Set(float64(w.pcache.Len()))
@@ -134,8 +134,7 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
}
func (w *ResponseWriter) set(m *dns.Msg, key int, mt response.Type, duration time.Duration) {
- if key == -1 {
- log.Printf("[ERROR] Caching called with empty cache key")
+ if key == -1 || duration == 0 {
return
}