Software /
code /
prosody
Diff
util/cache.lua @ 6943:0a31ec3193f0
util.cache: Make sure cache size is specified as an integer
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 25 Nov 2015 20:49:41 +0100 |
parent | 6933:d636815d81c3 |
child | 6945:d779c55058c6 |
line wrap: on
line diff
--- a/util/cache.lua Wed Nov 25 20:43:29 2015 +0100 +++ b/util/cache.lua Wed Nov 25 20:49:41 2015 +0100 @@ -2,6 +2,8 @@ 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);