lights FAQ Forum github.com/luapower/lrucache_lua
lrucache_lua

Misc
fonts-awesome
fonts-ionicons
fonts-material-icons
fonts-noto-emoji
fonts-open-sans
lrucache_lua
rangelist
utf8quot

lrucache_lua

Size-limited LRU cache in Lua


local lrucache = require'lrucache'

LRU cache limited by an abstract size. Values can have different sizes. When a new value is put in the cache and the cache is full, just enough old values are removed to make room for the new value and not exceed the cache max size.

API

lrucache([options]) -> cache create a new cache
cache.max_size <- size set the cache size limit
cache:clear() clear the cache
cache:free() destroy the cache
cache:free_value(val) value destructor (to be overriden)
cache:value_size(val) -> size get value size (to be overriden; returns 1)
cache:free_size() -> size size left until max_size
cache:get(key) -> val get a value from the cache by key
cache:remove(key) -> val remove a value from the cache by key
cache:remove_val(val) -> key remove a value from the cache
cache:remove_last() -> val remove the last value from the cache
cache:put(key, val) put a value in the cache, making room as needed

Last updated: 3 months ago | Edit on GitHub

Pkg type:Lua
Version: r1-4-g1a537c9
Last commit:
License: Public Domain
Requires: none
Required by: none

Top