ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Cache.Store

Description

Local request coalescing with optional, separately owned retention.

Synopsis

Documentation

data SingleFlight e k v Source #

Active requests own flight results. Completion removes the only registry reference.

newSingleFlightWithBackend :: Maybe (RetentionBackend k v) -> IO (SingleFlight e k v) Source #

Coalesce requests without retaining completed values when the backend is absent.

resolveSingleFlight :: Ord k => (CacheResult -> IO ()) -> (CacheOccupancy -> IO ()) -> IO () -> SingleFlight e k v -> k -> IO (Either e v) -> IO (Either e v) Source #

Share active work and release waiters on failure or cancellation. Capacity refusals and external backend faults use the refusal callback.

data PreparedStore e v Source #

A request-scoped read with any local value already pinned. Execute it once.

prepareStore :: Ord k => (CacheResult -> IO ()) -> (CacheOccupancy -> IO ()) -> IO () -> SingleFlight e k v -> k -> IO (Either e v) -> IO (PreparedStore e v) Source #

Capture local retention without claiming a flight or contacting external storage.

executePrepared :: PreparedStore e v -> IO (Either e v) Source #

Resolve the read, recording its request outcome only during execution.

lookupStore :: (CacheOccupancy -> IO ()) -> IO () -> Recency -> SingleFlight e k v -> k -> IO (Maybe v) Source #

Probe the selected storage. Recency is a hint, and unsupported retention reports zero occupancy.

data CacheOccupancy Source #

Entry count and summed accounted bytes after a store mutation.

Constructors

CacheOccupancy 

Fields