core/container/lru

container_lru

Types

2

Cache

Cache :: struct {}Source

Cache is an LRU cache. It automatically removes entries as new entries are added if the capacity is reached. Entries are removed based on how recently they were used where the oldest entries are removed first.

Procedures

9

exists

exists :: proc(c: ^C, key: Key) -> (bool)Source

exists checks for the existence of a value from a given key without updating the recent usage.

get

get :: proc(c: ^C, key: Key) -> (value: Value, ok: bool)Source

get a value from the cache from a given key. This operation updates the usage of the item.

get_ptr

get_ptr :: proc(c: ^C, key: Key) -> (value: ^Value, ok: bool)Source

get_ptr gets the pointer to a value the cache from a given key. This operation updates the usage of the item.

init

init :: proc(c: ^C, capacity: int, entries_allocator: mem.Allocator = context.allocator, node_allocator: mem.Allocator = context.allocator)Source

init initializes a Cache

peek

peek :: proc(c: ^C, key: Key) -> (value: Value, ok: bool)Source

peek gets the value from the cache from a given key without updating the recent usage.

set

set :: proc(c: ^C, key: Key, value: Value) -> (runtime.Allocator_Error)Source

set the given key value pair. This operation updates the recent usage of the item.

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.