A least-recently-used (`LRU`) cache. It automatically removes older entries if its capacity is reached.

Collection Info

View Source
Collection
core
Path
container/lru
Entries
11

Source Files

Types

2

Cache #

Source
Cache :: Cache

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

clear #

Source
clear :: proc(c: ^$C/Cache($Key, $Value), call_on_remove: bool) {…}

clear the contents of a Cache

destroy #

Source
destroy :: proc(c: ^$C/Cache($Key, $Value), call_on_remove: bool) {…}

destroy deinitializes a Cachem

exists #

Source
exists :: proc(c: ^$C/Cache($Key, $Value), key: $Key) -> bool {…}

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

get #

Source
get :: proc(c: ^$C/Cache($Key, $Value), key: $Key) -> (value: $$deferred_return, ok: bool) #optional_ok {…}

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

get_ptr #

Source
get_ptr :: proc(c: ^$C/Cache($Key, $Value), key: $Key) -> (value: $$deferred_return, ok: bool) #optional_ok {…}

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

init #

Source
init :: proc(c: ^$C/Cache($Key, $Value), capacity: int, entries_allocator := context.allocator, node_allocator := context.allocator) {…}

init initializes a Cache

peek #

Source
peek :: proc(c: ^$C/Cache($Key, $Value), key: $Key) -> (value: $$deferred_return, ok: bool) #optional_ok {…}

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

remove #

Source
remove :: proc(c: ^$C/Cache($Key, $Value), key: $Key) -> bool {…}

remove removes an item from the cache.

set #

Source
set :: proc(c: ^$C/Cache($Key, $Value), key: $Key, value: $Value) -> Allocator_Error {…}

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