]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
gc: keep root and TLD data in cache as much as possible
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 25 Jun 2019 11:01:06 +0000 (13:01 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 10 Jul 2019 13:59:23 +0000 (15:59 +0200)
utils/cache_gc/categories.c

index c64f6d20af38a5dcd9b59e7386fe0fc0efa3b449..2e49baf1893a17ce20d807dbe3fa717d3db0fe6a 100644 (file)
@@ -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);