summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPetr Špaček <petr.spacek@nic.cz>2019-06-25 13:01:06 +0200
committerPetr Špaček <petr.spacek@nic.cz>2019-07-10 15:59:23 +0200
commitdbbeea7597dcc4f04191ba94610e2315f4050ef5 (patch)
treef101f822948d455339a7c0a1ea43472dc2bba265 /utils
parentgc: delete inconsistent entries from cache instead of skipping them (diff)
downloadknot-resolver-dbbeea7597dcc4f04191ba94610e2315f4050ef5.tar.xz
knot-resolver-dbbeea7597dcc4f04191ba94610e2315f4050ef5.zip
gc: keep root and TLD data in cache as much as possible
Diffstat (limited to 'utils')
-rw-r--r--utils/cache_gc/categories.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/utils/cache_gc/categories.c b/utils/cache_gc/categories.c
index c64f6d20..2e49baf1 100644
--- a/utils/cache_gc/categories.c
+++ b/utils/cache_gc/categories.c
@@ -27,30 +27,28 @@ static int get_random(int to)
// TODO this is just an example, make this more clever
category_t kr_gc_categorize(gc_record_info_t *info)
{
- category_t res = 60;
+ category_t res;
+
if (!info->valid)
return CATEGORIES - 1;
switch (info->no_labels) {
- case 0:
+ case 0: /* root zone */
res = 5;
break;
- case 1:
+ case 1: /* TLD */
res = 10;
break;
- case 2:
+ default: /* SLD and below */
res = (rrtype_is_infrastructure(info->rrtype) ? 15 : 20);
+ if (info->entry_size > 300)
+ /* Penalty for big answers */
+ res += 30;
break;
}
- if (info->entry_size > 300) {
- res += 30;
- }
-
- if (rrtype_is_infrastructure(info->rrtype)) {
- if (info->expires_in > 0) {
- res = res > 40 ? 40 : res;
- }
+ if (info->expires_in <= 0) {
+ res += 40;
}
return res + get_random(5);