Commit d208e7e5 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček

cache TTL limit nitpicks: allow equality, fix docs

I also tried making a clickable define in the docs,
like for cache.ns_tout(), but I failed.
parent b1190fa7
......@@ -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.
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment