aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/cache.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/cache.lua b/util/cache.lua
index d3639b3f..e53bf4bf 100644
--- a/util/cache.lua
+++ b/util/cache.lua
@@ -92,6 +92,18 @@ function cache_methods:count()
return self._count;
end
+function cache_methods:head()
+ local head = self._head;
+ if not head then return nil, nil; end
+ return head.key, head.value;
+end
+
+function cache_methods:tail()
+ local tail = self._tail;
+ if not tail then return nil, nil; end
+ return tail.key, tail.value;
+end
+
local function new(size, on_evict)
size = assert(tonumber(size), "cache size must be a number");
size = math.floor(size);