diff --git a/daemon/bindings.c b/daemon/bindings.c index cff98a205ab664190c4d85798c80ebca99e738c3..f21e3835a8e3536e369b009841047658f03a11b0 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -285,6 +285,21 @@ int lib_net(lua_State *L) return 1; } +/** Return available cached backends. */ +static int cache_backends(lua_State *L) +{ + struct engine *engine = engine_luaget(L); + storage_registry_t *registry = &engine->storage_registry; + + lua_newtable(L); + for (unsigned i = 0; i < registry->len; ++i) { + struct storage_api *storage = ®istry->at[i]; + lua_pushboolean(L, storage->api() == kr_cache_storage()); + lua_setfield(L, -2, storage->prefix); + } + return 1; +} + /** Return number of cached records. */ static int cache_count(lua_State *L) { @@ -377,6 +392,7 @@ static int cache_close(lua_State *L) int lib_cache(lua_State *L) { static const luaL_Reg lib[] = { + { "backends", cache_backends }, { "count", cache_count }, { "open", cache_open }, { "close", cache_close }, diff --git a/lib/cache.h b/lib/cache.h index 83b7225a7e22aec7ad0e360240b8a68d5a4d9fe9..647169caa7416ce32953512b4aad1529ded3c993 100644 --- a/lib/cache.h +++ b/lib/cache.h @@ -105,6 +105,7 @@ struct kr_cache_entry *kr_cache_peek(namedb_txn_t *txn, uint8_t tag, const knot_ * @param name asset name * @param type asset type * @param header filled entry header (count, ttl and timestamp) + * @param data inserted data * @return 0 or an errcode */ int kr_cache_insert(namedb_txn_t *txn, uint8_t tag, const knot_dname_t *name, uint16_t type,