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.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go
index 2a56500a3..5673cc948 100644
--- a/plugin/cache/cache.go
+++ b/plugin/cache/cache.go
@@ -190,7 +190,9 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration
switch mt {
case response.NoError, response.Delegation:
i := newItem(m, w.now(), duration)
- w.pcache.Add(key, i)
+ if w.pcache.Add(key, i) {
+ evictions.WithLabelValues(w.server, Success).Inc()
+ }
// when pre-fetching, remove the negative cache entry if it exists
if w.prefetch {
w.ncache.Remove(key)
@@ -198,7 +200,9 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration
case response.NameError, response.NoData, response.ServerError:
i := newItem(m, w.now(), duration)
- w.ncache.Add(key, i)
+ if w.ncache.Add(key, i) {
+ evictions.WithLabelValues(w.server, Denial).Inc()
+ }
case response.OtherError:
// don't cache these