class

Fetcher::Cache

Inherits Reference < Object

Constants

DEFAULT_TTL = 5.minutes

Constructors

new(max_size : Int32 = 1000, enabled : Bool = true, store : CacheStore | Nil = nil)

Keep instance constructor compatible with existing tests / usage that create Cache instances. Instances are lightweight facades over their own CacheStore so tests and callers that expect isolated caches continue to work. Constructor: keep backwards-compatible signature but allow injecting a CacheStore. If store is provided, the Cache instance will wrap that store (useful for sharing a store across many Cache instances). If not provided, a new per-instance CacheStore is created (preserves legacy behavior).

Source

Class methods

clear
Source
clear_by_prefix(prefix : String) : Void
Source
default
Source
default_store=(store : CacheStore)

Replace the default/shared store used by class-level Cache methods. This allows applications to inject a shared CacheStore instance for global caching without relying on global state construction.

Source
enabled=(value : Bool)
Source
enabled?
Source
get(key : String) : Result | Nil
Source
max_size
Source
max_size=(value : Int32)
Source
set(key : String, value : Result, ttl : Time::Span = DEFAULT_TTL) : Nil
Source
stats
Source
store
Source
use_default_store(max_size : Int32 = 1000, enabled : Bool = true) : Nil

Convenience: create and set a shared default store with the provided configuration.

Source

Instance methods

clear
Source
clear_by_prefix(prefix : String)
Source
close

Close the underlying CacheStore, stopping its owner fiber. Call this when the cache instance is no longer needed.

Source
enabled=(value : Bool)
Source
enabled?
Source
get(key : String) : Result | Nil

Instance API (delegate to the instance-local store)

Source
max_size
Source
max_size=(value : Int32)
Source
set(key : String, value : Result, ttl : Time::Span = DEFAULT_TTL)
Source
stats
Source