aboutsummaryrefslogtreecommitdiffstats
path: root/util/cache.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-11-25 20:49:41 +0100
committerKim Alvefur <zash@zash.se>2015-11-25 20:49:41 +0100
commit1ae6748835396bf66a5825b38369077b34582f9a (patch)
tree7959e98690bcf2fb80047b1145a5c94ca29167a9 /util/cache.lua
parent8e63a2bd3bd94e13c9950543da3859d512838e11 (diff)
downloadprosody-1ae6748835396bf66a5825b38369077b34582f9a.tar.gz
prosody-1ae6748835396bf66a5825b38369077b34582f9a.zip
util.cache: Make sure cache size is specified as an integer
Diffstat (limited to 'util/cache.lua')
-rw-r--r--util/cache.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/util/cache.lua b/util/cache.lua
index 9453697c..32670751 100644
--- a/util/cache.lua
+++ b/util/cache.lua
@@ -2,6 +2,8 @@ local cache_methods = {};
local cache_mt = { __index = cache_methods };
local function new(size)
+ size = assert(tonumber(size), "cache size must be a number");
+ size = math.floor(size);
assert(size > 0, "cache size must be greater than zero");
local data = {};
return setmetatable({ data = data, count = 0, size = size, head = nil, tail = nil }, cache_mt);