aboutsummaryrefslogtreecommitdiffstats
path: root/util/cache.lua
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
commit41d8ce349314d6faaabe877d0eda10b59cc76743 (patch)
tree2540fa8f116cf725d4fc9dc978c1845d921a1ccf /util/cache.lua
parent01d628a5476f08dc53feb8700819360f8e38f0b9 (diff)
downloadprosody-41d8ce349314d6faaabe877d0eda10b59cc76743.tar.gz
prosody-41d8ce349314d6faaabe877d0eda10b59cc76743.zip
util.cache: Add method for removing all data (does not call eviction callback)
Diffstat (limited to 'util/cache.lua')
-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);