diff --git a/daemon/README.rst b/daemon/README.rst index 975c01c1bf4dea08a7387365a89204dcd21ee407..3ec8c8025d6ba94e30a32dc969b41792557ac8a7 100644 --- a/daemon/README.rst +++ b/daemon/README.rst @@ -718,7 +718,10 @@ daemons or manipulated from other processes, making for example synchronised loa .. function:: cache.max_ttl([ttl]) - :param number ttl: maximum cache TTL (default: 6 days) + :param number ttl: maximum cache TTL in seconds (default: 6 days) + + .. KR_CACHE_DEFAULT_TTL_MAX ^^ + :return: current maximum TTL Get or set maximum cache TTL. @@ -738,7 +741,10 @@ daemons or manipulated from other processes, making for example synchronised loa .. function:: cache.min_ttl([ttl]) - :param number ttl: minimum cache TTL (default: 0) + :param number ttl: minimum cache TTL in seconds (default: 5 seconds) + + .. KR_CACHE_DEFAULT_TTL_MIN ^^ + :return: current maximum TTL Get or set minimum cache TTL. Any entry inserted into cache with TTL lower than minimal will be overriden to minimum TTL. Forcing TTL higher than specified violates DNS standards, use with care. diff --git a/daemon/bindings.c b/daemon/bindings.c index bcb9daa2141b16b6f2cc5b68e04ca372ba650e4b..f3c6e1cb7521e5bff74ad006c824ea2e23fda2f5 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -808,7 +808,7 @@ static int cache_max_ttl(lua_State *L) } uint32_t min = cache->ttl_min; int64_t ttl = lua_tonumber(L, 1); - if (ttl < 0 || ttl <= min || ttl > UINT32_MAX) { + if (ttl < 0 || ttl < min || ttl > UINT32_MAX) { format_error(L, "max_ttl must be larger than minimum TTL, and in range <1, " xstr(UINT32_MAX) ">'"); lua_error(L); } @@ -832,7 +832,7 @@ static int cache_min_ttl(lua_State *L) } uint32_t max = cache->ttl_max; int64_t ttl = lua_tonumber(L, 1); - if (ttl < 0 || ttl >= max || ttl > UINT32_MAX) { + if (ttl < 0 || ttl > max || ttl > UINT32_MAX) { format_error(L, "min_ttl must be smaller than maximum TTL, and in range <0, " xstr(UINT32_MAX) ">'"); lua_error(L); }