protocol
lru_cache_protocol
LRU (Least Recently Used) cache protocol. Key-value pairs are represented as Key-Value.
logtalk_load(lru_caches(loader))staticPublic predicates
new/2
Creates a new empty cache with the given maximum capacity.
staticnew(Capacity,Cache)new(+non_negative_integer,-cache) - one_or_errorCapacity is a variable:instantiation_errorCapacity is neither a variable nor an integer:type_error(integer,Capacity)Capacity is an integer but is less than zero:domain_error(non_negative_integer,Capacity)capacity/2
Returns the maximum cache capacity.
staticcapacity(Cache,Capacity)capacity(+cache,-non_negative_integer) - onesize/2
Returns the number of entries in the cache.
staticsize(Cache,Size)size(+cache,-non_negative_integer) - oneempty/1
True iff the cache is empty.
staticempty(Cache)empty(+cache) - zero_or_onelookup/3
Looks up a matching key-value pair without changing its recency. Fails if the key is not found or the value does not unify.
staticlookup(Key,Value,Cache)lookup(+ground,?term,+cache) - zero_or_one_or_errorKey is not ground:instantiation_errorget/4
Looks up a matching key-value pair and marks it as most recently used, returning the updated cache. Fails if the key is not found or the value does not unify.
staticget(Key,Value,Cache,NewCache)get(+ground,?term,+cache,-cache) - zero_or_one_or_errorKey is not ground:instantiation_errorput/4
Inserts or replaces a key-value pair, marks it as most recently used, and evicts the least recently used entry when necessary.
staticput(Key,Value,Cache,NewCache)put(+ground,+term,+cache,-cache) - one_or_errorKey is not ground:instantiation_errorupdate/5
Updates an existing matching key-value pair and marks it as most recently used. Fails if the key is not found or the old value does not unify.
staticupdate(Key,OldValue,NewValue,Cache,NewCache)update(+ground,?term,+term,+cache,-cache) - zero_or_one_or_errorKey is not ground:instantiation_errordelete/4
Deletes a matching key-value pair, returning the updated cache. Fails if the key is not found or the value does not unify.
staticdelete(Key,Value,Cache,NewCache)delete(+ground,?term,+cache,-cache) - zero_or_one_or_errorKey is not ground:instantiation_errorevict/3
Evicts and returns the least recently used key-value pair. Fails if the cache is empty.
staticevict(Cache,Pair,NewCache)evict(+cache,-pair,-cache) - zero_or_oneas_list/2
Returns the cache key-value pairs ordered from most recently used to least recently used.
staticas_list(Cache,Pairs)as_list(+cache,-list(pair)) - oneclear/2
Returns an empty cache with the same capacity.
staticclear(Cache,EmptyCache)clear(+cache,-cache) - oneProtected predicates
(none)
Private predicates
(none)
Operators
(none)
See also