From b44d82839facb4911f03f6a8e6003529a01c67bf Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 8 Oct 2016 15:12:28 +0100 Subject: [PATCH] middleware/cache: rename categories (#321) Rename: positive -> success negative -> denial There is a third (unused category) which is error. Start using these new in the caching middleware and later in the logging middleware. --- middleware/cache/README.md | 12 +++++++----- middleware/cache/cache.go | 2 +- middleware/cache/setup.go | 4 ++-- middleware/cache/setup_test.go | 18 +++++++++++------- middleware/file/README.md | 1 - 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/middleware/cache/README.md b/middleware/cache/README.md index 54eb82b73..c9a678983 100644 --- a/middleware/cache/README.md +++ b/middleware/cache/README.md @@ -9,7 +9,7 @@ cache [ttl] [zones...] ~~~ * `ttl` max TTL in seconds. If not specified, the maximum TTL will be used which is 1 hour for - positive responses and half an hour for negative ones. + noerror responses and half an hour for denial of existence ones. * `zones` zones it should cache for. If empty, the zones from the configuration block are used. Each element in the cache is cached according to its TTL (with `ttl` as the max). @@ -20,17 +20,19 @@ Or if you want more control: ~~~ txt cache [ttl] [zones...] { - postive capacity [ttl] - negative capacity [ttl] + noerror capacity [ttl] + denial capacity [ttl] } ~~~ * `ttl` and `zones` as above. -* `positive`, override the settings for caching positive responses, capacity indicates the maximum +* `success`, override the settings for caching noerror responses, capacity indicates the maximum number of packets we cache before we start evicting (LRU). Ttl overrides the cache maximum TTL. -* `negative`, override the settings for caching negative responses, capacity indicates the maximum +* `denial`, override the settings for caching denial of existence responses, capacity indicates the maximum number of packets we cache before we start evicting (LRU). Ttl overrides the cache maximum TTL. +There is a third category (`error`) but those responses are never cached. + The minimum TTL allowed on resource records is 5 seconds. If monitoring is enabled (via the `prometheus` directive) then the following extra metrics are added: diff --git a/middleware/cache/cache.go b/middleware/cache/cache.go index 682739eef..091638655 100644 --- a/middleware/cache/cache.go +++ b/middleware/cache/cache.go @@ -15,7 +15,7 @@ import ( ) // Cache is middleware that looks up responses in a cache and caches replies. -// It has a positive and a negative cache. +// It has a success and a denial of existence cache. type Cache struct { Next middleware.Handler Zones []string diff --git a/middleware/cache/setup.go b/middleware/cache/setup.go index de90d3acb..08c8fefdb 100644 --- a/middleware/cache/setup.go +++ b/middleware/cache/setup.go @@ -58,7 +58,7 @@ func cacheParse(c *caddy.Controller) (*Cache, error) { for c.NextBlock() { switch c.Val() { // first number is cap, second is an new ttl - case "positive": + case "success": args := c.RemainingArgs() if len(args) == 0 { return nil, c.ArgErr() @@ -75,7 +75,7 @@ func cacheParse(c *caddy.Controller) (*Cache, error) { } ca.pttl = time.Duration(pttl) * time.Second } - case "negative": + case "denial": args := c.RemainingArgs() if len(args) == 0 { return nil, c.ArgErr() diff --git a/middleware/cache/setup_test.go b/middleware/cache/setup_test.go index 493ade5a7..ee8976a49 100644 --- a/middleware/cache/setup_test.go +++ b/middleware/cache/setup_test.go @@ -19,22 +19,26 @@ func TestSetup(t *testing.T) { {`cache`, false, defaultCap, defaultCap, maxNTTL, maxTTL}, {`cache {}`, false, defaultCap, defaultCap, maxNTTL, maxTTL}, {`cache example.nl { - positive 10 + success 10 }`, false, defaultCap, 10, maxNTTL, maxTTL}, {`cache example.nl { - positive 10 - negative 10 15 + success 10 + denial 10 15 }`, false, 10, 10, 15 * time.Second, maxTTL}, {`cache 25 example.nl { - positive 10 - negative 10 15 + success 10 + denial 10 15 }`, false, 10, 10, 15 * time.Second, 25 * time.Second}, {`cache aaa example.nl`, false, defaultCap, defaultCap, maxNTTL, maxTTL}, // fails {`cache example.nl { - positive - negative 10 15 + success + denial 10 15 + }`, true, defaultCap, defaultCap, maxTTL, maxTTL}, + {`cache example.nl { + success 15 + denial aaa }`, true, defaultCap, defaultCap, maxTTL, maxTTL}, {`cache example.nl { positive 15 diff --git a/middleware/file/README.md b/middleware/file/README.md index bb7bfbdd7..34a9af043 100644 --- a/middleware/file/README.md +++ b/middleware/file/README.md @@ -24,7 +24,6 @@ TSIG key information, something like `transfer out [address...] key [name] [base ~~~ file dbfile [zones... ] { - transfer from [address...] transfer to [address...] no_reload }