howdy/cache/memory
A cache store in this node’s memory, in ETS tables.
let app_cache = cache.new(memory.new(max_entries: 50_000))
The fastest store, and the right one for a single node. Each node has
its own: an invalidate on one node does not reach the others, so an
app running on several nodes that invalidates by tag needs
howdy/cache/database, or short enough expiry times that a stale
value for that long is acceptable. A restart empties it.
The tables belong to the process that called new and are deleted
when it exits. Create the store in main, or in a process that lives
as long as the app, not inside a handler.
Values
pub fn new(max_entries max_entries: Int) -> cache.Store
A store holding about max_entries entries. When it is full, a write
first removes expired entries, then the entries closest to expiring
until a tenth of the room is free. Writers racing each other can each
go one over the limit until the next write; a sweep every minute
removes expired entries and trims back to the limit.
pub fn sweeping(
max_entries max_entries: Int,
every sweep_every: Int,
) -> cache.Store
Like new, sweeping expired entries every sweep_every milliseconds.