aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/setup.go
diff options
context:
space:
mode:
authorGravatar Aaron Riekenberg <aaron.riekenberg@gmail.com> 2018-09-03 14:26:02 -0500
committerGravatar Tobias Schmidt <tobidt@gmail.com> 2018-09-03 21:26:02 +0200
commitb42eae7a04b8f789d7a20c0664895cd8e4638a22 (patch)
treece3c4fe568fda2368e9c103451d6c4364ac1e349 /plugin/cache/setup.go
parent4c6c9d4b2700c3e4606d4b98bde64e7c1ed0c231 (diff)
downloadcoredns-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.go22
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()