ScopedCache
Constructors
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>;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
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
Added in v2.0.0
Source
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
ScopedCache
Added in v2.0.0
Source
Symbols
ScopedCacheTypeId
Added in v2.0.0
Source
Signature
declare const ScopedCacheTypeId: unique symbol;ScopedCacheTypeId type
Added in v2.0.0
Source
Signature
type ScopedCacheTypeId = typeof ScopedCacheTypeId;
Constructs a new cache with the specified capacity, time to live, and lookup function.