From 41d8ce349314d6faaabe877d0eda10b59cc76743 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 7 Nov 2017 00:38:47 +0100 Subject: util.cache: Add method for removing all data (does not call eviction callback) --- util/cache.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'util') 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); -- cgit v1.2.3