Added lru-use function

This commit is contained in:
2026-05-17 21:55:50 +02:00
parent 8e1752c7ad
commit d8d50515f6
2 changed files with 56 additions and 17 deletions
+9
View File
@@ -74,6 +74,15 @@ If capacity is reached, the least recently used item is removed.
Returns @racket[l].
}
@defproc[(lry-use [l lru?] [key any/c] [default any/c]) any/c]{
Finds the given @racket[item] by @racket[key] (this must be accomodated
in the compare function (see @tt{#:cmp}). When the item is found
using the key, it will not only return the item, but also move the
item to the front of the cache and update the expiry parameter.
When the item is not found, it will return @racket{default}.
}
@defproc[(lru-has? [l lru?] [item any/c]) boolean?]{
Returns @racket[#t] if @racket[item] is currently present (and not expired),
otherwise @racket[#f]. This call also performs lazy cleanup of expired items.