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 | 41d8ce349314d6faaabe877d0eda10b59cc76743 (patch) | |
tree | 2540fa8f116cf725d4fc9dc978c1845d921a1ccf | |
parent | 01d628a5476f08dc53feb8700819360f8e38f0b9 (diff) | |
download | prosody-41d8ce349314d6faaabe877d0eda10b59cc76743.tar.gz prosody-41d8ce349314d6faaabe877d0eda10b59cc76743.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); |