class

Alumna::MemoryCache

Inherits Alumna::Cache < Reference < Object

In-process byte cache. Use one instance per process (single backend). Swap for a Redis Cache to share entries across processes.

Expiry uses Time.instant (monotonic). No background fiber. Expired rows are dropped on get and by an amortized prune every cleanup_every writes/reads, same as MemorySessionStore.

Constructors

new(cleanup_every : Int32 = 1024)
Source

Instance methods

delete(key : String) : Nil
Source
get(key : String) : Bytes | Nil
Source
incr(key : String) : Int64

Atomic +1. Missing, expired, or non-integer values start at 1. The stored counter has no TTL.

Source
prune_expired

Spec helper. Not used by the cache rule.

Source
set(key : String, value : Bytes, ttl : Time::Span | Nil = nil) : Nil
Source
set_nx(key : String, value : Bytes, ttl : Time::Span | Nil = nil) : Bool

True if the key was missing or expired and this call stored the value.

Source
size

Spec helper. Not used by the cache rule.

Source

Nested types