{
/* Check cache ABI version */
knot_db_val_t key = { KEY_VERSION, 2 };
- knot_db_val_t val = { NULL, 0 };
+ knot_db_val_t val = { KEY_VERSION, 2 };
int ret = cache_op(cache, read, &key, &val, 1);
if (ret == 0) {
ret = kr_error(EEXIST);
} else {
- /*
- * Version doesn't match.
- * Recreate cache and write version key.
- */
+ /* Version doesn't match. Recreate cache and write version key. */
ret = cache_op(cache, count);
if (ret != 0) { /* Non-empty cache, purge it. */
kr_log_info("[cache] purging cache\n");
}
/* Either purged or empty. */
if (ret == 0) {
+ /* Key/Val is invalidated by cache purge, recreate it */
+ key.data = KEY_VERSION;
+ key.len = 2;
+ val = key;
ret = cache_op(cache, write, &key, &val, 1);
}
}
+ cache_op(cache, sync);
return ret;
}
return mock();
}
+static int fake_test_sync(knot_db_t *db)
+{
+ return 0;
+}
+
static void fake_test_deinit(knot_db_t *db)
{
}
{
static const struct kr_cdb_api api = {
"lmdb_fake_api",
- fake_test_init, fake_test_deinit, NULL, NULL, NULL,
+ fake_test_init, fake_test_deinit, NULL, NULL, fake_test_sync,
fake_test_find, fake_test_ins, NULL,
NULL, NULL
};