summaryrefslogtreecommitdiffstats
path: root/python/knot_resolver/datamodel/templates/cache.lua.j2
diff options
context:
space:
mode:
Diffstat (limited to 'python/knot_resolver/datamodel/templates/cache.lua.j2')
-rw-r--r--python/knot_resolver/datamodel/templates/cache.lua.j232
1 files changed, 32 insertions, 0 deletions
diff --git a/python/knot_resolver/datamodel/templates/cache.lua.j2 b/python/knot_resolver/datamodel/templates/cache.lua.j2
new file mode 100644
index 00000000..f0176a59
--- /dev/null
+++ b/python/knot_resolver/datamodel/templates/cache.lua.j2
@@ -0,0 +1,32 @@
+cache.open({{ cfg.cache.size_max.bytes() }}, 'lmdb://{{ cfg.cache.storage }}')
+cache.min_ttl({{ cfg.cache.ttl_min.seconds() }})
+cache.max_ttl({{ cfg.cache.ttl_max.seconds() }})
+cache.ns_tout({{ cfg.cache.ns_timeout.millis() }})
+
+{% if cfg.cache.prefill %}
+-- cache.prefill
+modules.load('prefill')
+prefill.config({
+{% for item in cfg.cache.prefill %}
+ ['{{ item.origin.punycode() }}'] = {
+ url = '{{ item.url }}',
+ interval = {{ item.refresh_interval.seconds() }}
+ {{ "ca_file = '"+item.ca_file+"'," if item.ca_file }}
+ }
+{% endfor %}
+})
+{% endif %}
+
+{% if cfg.cache.prefetch.expiring %}
+-- cache.prefetch.expiring
+modules.load('prefetch')
+{% endif %}
+
+{% if cfg.cache.prefetch.prediction %}
+-- cache.prefetch.prediction
+modules.load('predict')
+predict.config({
+ window = {{ cfg.cache.prefetch.prediction.window.minutes() }},
+ period = {{ cfg.cache.prefetch.prediction.period }},
+})
+{% endif %}