Software /
code /
prosody
Changeset
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 |
parents | 6942:f12deb882148 |
children | 6944:62b6f6d230f1 |
files | util/cache.lua |
diffstat | 1 files changed, 2 insertions(+), 0 deletions(-) [+] |
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);