Pudu programming language
Menu
API reference

Std.LruCache.LruCache

1 declaration

type

LruCache

This declaration introduces a public type.

What it does

A map that holds only so much, and gives up what has gone longest unused.

A cache without a bound is a map that only grows, which is a leak with a

helpful name. The bound is the whole point: memoised results, parsed files,

recently opened documents all want to keep what is being used and let go of

what is not, and none of them can afford to keep everything.

Least recently used, not least recently written — so reading an entry

keeps it alive. That is what separates a cache from a queue, and it is why

get answers both the value and a cache: the read changed which entry is

next to go, and hiding that would make the order depend on reads a caller

could not see.

The recency order comes from LinkedMap.touch, which already exists to move

a key to the end of an order. Nothing here re-implements it.

Read the signature

  • This declaration has no value signature because it introduces a type or trait.

Back to Std.LruCacheSearch related declarations