Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

ScopedCache

7 exports Since v2.0.0 Source

Constructors

Since v2.0.0

Constructs a new cache with the specified capacity, time to live, and lookup function.

Signature

declare const make: <Key, Value, Error = never, Environment = never>(options: {
readonly capacity: number;
readonly lookup: Lookup<Key, Value, Error, Environment>;
readonly timeToLive: Duration.DurationInput;
}) => Effect.Effect<ScopedCache<Key, Value, Error>, never, Scope.Scope | Environment>
Since v2.0.0

Constructs a new cache with the specified capacity, time to live, and lookup function, where the time to live can depend on the Exit value returned by the lookup function.

Signature

declare const makeWith: <Key, Value, Error = never, Environment = never>(options: {
readonly capacity: number;
readonly lookup: Lookup<Key, Value, Error, Environment>;
readonly timeToLive: (exit: Exit.Exit<Value, Error>) => Duration.DurationInput;
}) => Effect.Effect<ScopedCache<Key, Value, Error>, never, Scope.Scope | Environment>

Models

Since v2.0.0

Similar to Cache.Lookup, but executes the lookup function within a Scope.

Signature

type Lookup<Key, Value, Error = never, Environment = never> = (key: Key) => Effect.Effect<Value, Error, Environment | Scope.Scope>

ScopedCache

interface
Since v2.0.0

Signature

interface ScopedCache<in Key, out Value, out Error = never> extends Variance<Key, Value, Error>, Pipeable {
readonly cacheStats: Effect<CacheStats>;
readonly invalidateAll: Effect<void>;
readonly size: Effect<number>;
contains(key: Key): Effect<boolean>;
entryStats(key: Key): Effect<Option<EntryStats>>;
get(key: Key): Effect<Value, Error, Scope>;
getOption(key: Key): Effect<Option<Value>, Error, Scope>;
getOptionComplete(key: Key): Effect<Option<Value>, never, Scope>;
invalidate(key: Key): Effect<void>;
refresh(key: Key): Effect<void, Error>;
}

Other

Symbols

Signature

declare const ScopedCacheTypeId: unique symbol

Signature

type ScopedCacheTypeId = typeof ScopedCacheTypeId