diff options
author | Kim Alvefur <zash@zash.se> | 2017-11-07 00:38:47 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-11-07 00:38:47 +0100 |
commit | 53c29410bd763ac42ec871bd2fc033019162e576 (patch) | |
tree | 2540fa8f116cf725d4fc9dc978c1845d921a1ccf | |
parent | ac9e52cd1c97e48a65f17fc0ba6c958320c41ada (diff) | |
download | prosody-53c29410bd763ac42ec871bd2fc033019162e576.tar.gz prosody-53c29410bd763ac42ec871bd2fc033019162e576.zip |
util.cache: Add method for removing all data (does not call eviction callback)
-rw-r--r-- | util/cache.lua | 7 |
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); |