Added lru-use function
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user