diff options
author | 2018-09-03 14:26:02 -0500 | |
---|---|---|
committer | 2018-09-03 21:26:02 +0200 | |
commit | b42eae7a04b8f789d7a20c0664895cd8e4638a22 (patch) | |
tree | ce3c4fe568fda2368e9c103451d6c4364ac1e349 /plugin/cache/setup.go | |
parent | 4c6c9d4b2700c3e4606d4b98bde64e7c1ed0c231 (diff) | |
download | coredns-b42eae7a04b8f789d7a20c0664895cd8e4638a22.tar.gz coredns-b42eae7a04b8f789d7a20c0664895cd8e4638a22.tar.zst coredns-b42eae7a04b8f789d7a20c0664895cd8e4638a22.zip |
Add MINTTL parameter to cache configuration. (#2055)
* Add success min TTL parameter to cache.
* Add MINTTL to README.
* Update README.
* Add MINTTL to negative cache.
* Remove unnecessary variable name.
* Address review comments.
* Configure cache in TestCacheZeroTTL to have 0 min ttl.
Diffstat (limited to 'plugin/cache/setup.go')
-rw-r--r-- | plugin/cache/setup.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugin/cache/setup.go b/plugin/cache/setup.go index 17a588885..8464c27d9 100644 --- a/plugin/cache/setup.go +++ b/plugin/cache/setup.go @@ -101,6 +101,17 @@ func cacheParse(c *caddy.Controller) (*Cache, error) { return nil, fmt.Errorf("cache TTL can not be zero or negative: %d", pttl) } ca.pttl = time.Duration(pttl) * time.Second + if len(args) > 2 { + minpttl, err := strconv.Atoi(args[2]) + if err != nil { + return nil, err + } + // Reserve < 0 + if minpttl < 0 { + return nil, fmt.Errorf("cache min TTL can not be negative: %d", minpttl) + } + ca.minpttl = time.Duration(minpttl) * time.Second + } } case Denial: args := c.RemainingArgs() @@ -122,6 +133,17 @@ func cacheParse(c *caddy.Controller) (*Cache, error) { return nil, fmt.Errorf("cache TTL can not be zero or negative: %d", nttl) } ca.nttl = time.Duration(nttl) * time.Second + if len(args) > 2 { + minnttl, err := strconv.Atoi(args[2]) + if err != nil { + return nil, err + } + // Reserve < 0 + if minnttl < 0 { + return nil, fmt.Errorf("cache min TTL can not be negative: %d", minnttl) + } + ca.minnttl = time.Duration(minnttl) * time.Second + } } case "prefetch": args := c.RemainingArgs() |