all: add local caching

This commit adds config params to enable local DNS response caching and
control its behavior, allow tweaking the cache size, ttl override and
serving stale response.
This commit is contained in:
Cuong Manh Le
2022-12-21 00:29:04 +07:00
committed by Cuong Manh Le
parent fa3c3e8a29
commit 30fefe7ab9
7 changed files with 192 additions and 10 deletions

View File

@@ -33,6 +33,8 @@ If no configuration files found, a default `config.toml` file will be created in
[service]
log_level = "info"
log_path = ""
cache_enable = true
cache_size = 4096
[network.0]
cidrs = ["0.0.0.0/0"]
@@ -109,6 +111,31 @@ Relative or absolute path of the log file.
- Type: string
- Required: no
### cache_enable
When `cache_enable = true`, all resolved DNS query responses will be cached for duration of the upstream record TTLs.
- Type: boolean
- Required: no
### cache_size
The number of cached records, must be a positive integer. Tweaking this value with care depends on your available RAM.
A minimum value `4096` should be enough for most use cases.
An invalid `cache_size` value will disable the cache, regardless of `cache_enable` value.
- Type: int
- Required: no
### cache_ttl_override
When `cache_ttl_override` is set to a positive value (in seconds), TTLs are overridden to this value and cached for this long.
- Type: int
- Required: no
### cache_serve_stale
When `cache_serve_stale = true`, in cases of upstream failures (upstreams not reachable), `ctrld` will keep serving
stale cached records (regardless of their TTLs) until upstream comes online.
The above config will look like this at query time.
```