typedef struct knot_dump_style knot_dump_style_t;
extern const knot_dump_style_t KNOT_DUMP_STYLE_DEFAULT;
+typedef void knot_db_t;
+struct kr_cdb_api {};
typedef struct knot_mm {
void *ctx, *alloc, *free;
knot_mm_t pool;
};
enum kr_rank {KR_RANK_INITIAL, KR_RANK_OMIT, KR_RANK_TRY, KR_RANK_INDET = 4, KR_RANK_BOGUS, KR_RANK_MISMATCH, KR_RANK_MISSING, KR_RANK_INSECURE, KR_RANK_AUTH = 16, KR_RANK_SECURE = 32};
+struct kr_cache
+{
+ knot_db_t *db;
+ const struct kr_cdb_api *api;
+ struct {
+ uint32_t hit;
+ uint32_t miss;
+ uint32_t insert;
+ uint32_t delete;
+ } stats;
+
+ uint32_t ttl_min, ttl_max;
+ struct timeval last_clear_walltime;
+ uint64_t last_clear_monotime;
+};
struct knot_rrset {
knot_dname_t *_owner;
uint16_t type;
map_t trust_anchors;
map_t negative_anchors;
struct kr_zonecut root_hints;
+ struct kr_cache cache;
char _stub[];
};
const char *knot_strerror(int code);
printf "
typedef struct knot_dump_style knot_dump_style_t;
extern const knot_dump_style_t KNOT_DUMP_STYLE_DEFAULT;
+typedef void knot_db_t;
+struct kr_cdb_api {};
"
# The generator doesn't work well with typedefs of functions.
struct kr_rplan
struct kr_request
enum kr_rank
+ struct kr_cache
EOF
genResType() {
genResType "struct kr_query"
-genResType "struct kr_context" | sed '/struct kr_cache/,$ d'
+genResType "struct kr_context" | sed '/kr_nsrep_lru_t/,$ d'
printf "\tchar _stub[];\n};\n"
## libknot API
is(cache.current_size, 50 * MB, 'cache was shrunk')
end
+-- test access to cache through context
+local function test_context_cache()
+ local c = kres.context().cache
+ is(type(c), 'cdata', 'context has a cache object')
+ local s = c.stats
+ same({s.hit, s.miss, s.insert, s.delete}, {0, 0, 0, 0}, 'context cache stats works')
+end
+
return {
test_properties,
test_stats,
test_resize,
+ test_context_cache,
}
\ No newline at end of file