diff options
-rw-r--r-- | spec/util_cache_spec.lua | 3 | ||||
-rw-r--r-- | util/cache.lua | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/spec/util_cache_spec.lua b/spec/util_cache_spec.lua index d4e609ed..ae7b1936 100644 --- a/spec/util_cache_spec.lua +++ b/spec/util_cache_spec.lua @@ -390,8 +390,7 @@ describe("util.cache", function() end); it("eviction stuff", function () - local c; - c = cache.new(4, function(_k,_v) + local c = cache.new(4, function(_k,_v,c) if c.size < 10 then c:resize(c.size*2); end diff --git a/util/cache.lua b/util/cache.lua index a72a535f..e1873cc8 100644 --- a/util/cache.lua +++ b/util/cache.lua @@ -55,7 +55,7 @@ function cache_methods:set(k, v) local tail = self._tail; local on_evict, evicted_key, evicted_value = self._on_evict, tail.key, tail.value; - local do_evict = on_evict and on_evict(evicted_key, evicted_value); + local do_evict = on_evict and on_evict(evicted_key, evicted_value, self); if do_evict == false then -- Cache is full, and we're not allowed to evict @@ -129,7 +129,7 @@ function cache_methods:resize(new_size) while self._count > new_size do local tail = self._tail; local evicted_key, evicted_value = tail.key, tail.value; - if on_evict ~= nil and (on_evict == false or on_evict(evicted_key, evicted_value) == false) then + if on_evict ~= nil and (on_evict == false or on_evict(evicted_key, evicted_value, self) == false) then -- Cache is full, and we're not allowed to evict return false; end |