# HG changeset patch # User Kim Alvefur # Date 1510011527 -3600 # Node ID fbe1f99fb245e196369beba4c5309fc045b8e3e3 # Parent fbb9a1c2120eff8807d64256d4ccd475780eed61 util.cache: Add method for removing all data (does not call eviction callback) diff -r fbb9a1c2120e -r fbe1f99fb245 util/cache.lua --- a/util/cache.lua Thu Nov 09 16:50:36 2017 +0100 +++ b/util/cache.lua Tue Nov 07 00:38:47 2017 +0100 @@ -139,6 +139,13 @@ 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);