aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-11-07 00:38:47 +0100
committerKim Alvefur <zash@zash.se>2017-11-07 00:38:47 +0100
commit53c29410bd763ac42ec871bd2fc033019162e576 (patch)
tree2540fa8f116cf725d4fc9dc978c1845d921a1ccf
parentac9e52cd1c97e48a65f17fc0ba6c958320c41ada (diff)
downloadprosody-53c29410bd763ac42ec871bd2fc033019162e576.tar.gz
prosody-53c29410bd763ac42ec871bd2fc033019162e576.zip
util.cache: Add method for removing all data (does not call eviction callback)
-rw-r--r--util/cache.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/cache.lua b/util/cache.lua
index 9c141bb6..d12551cc 100644
--- a/util/cache.lua
+++ b/util/cache.lua
@@ -139,6 +139,13 @@ function cache_methods:table()
return self.proxy_table;
end
+function cache_methods:clear()
+ self._data = {};
+ self._count = 0;
+ self._head = nil;
+ self._tail = nil;
+end
+
local function new(size, on_evict)
size = assert(tonumber(size), "cache size must be a number");
size = math.floor(size);