mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 05:37:39 +03:00
util.cache: Make sure cache size is specified as an integer
This commit is contained in:
parent
c8454e9180
commit
dd9e60beba
1 changed files with 2 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue