projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8ff8245
)
util.cache: Make sure cache size is specified as an integer
author
Kim Alvefur
<zash@zash.se>
Wed, 25 Nov 2015 19:49:41 +0000
(20:49 +0100)
committer
Kim Alvefur
<zash@zash.se>
Wed, 25 Nov 2015 19:49:41 +0000
(20:49 +0100)
util/cache.lua
patch
|
blob
|
history
diff --git
a/util/cache.lua
b/util/cache.lua
index 9453697ce8a00459afe152d53bdc2af3e6b2e5ca..32670751f8be5133186a770f4daa12248b63341f 100644
(file)
--- 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);