Skip to main content Link Search Menu Expand Document (external link)

Persistence overview

Added in v1.0.0


Table of contents


errors

PersistenceBackingError (class)

Signature

export declare class PersistenceBackingError

Added in v1.0.0

make (static method)

Signature

static make(method: string, cause: unknown)

Added in v1.0.0

PersistenceError (type alias)

Signature

export type PersistenceError = PersistenceParseError | PersistenceBackingError

Added in v1.0.0

PersistenceParseError (class)

Signature

export declare class PersistenceParseError

Added in v1.0.0

make (static method)

Signature

static make(method: string, error: ParseResult.ParseError["issue"])

Added in v1.0.0

layers

layerKeyValueStore

Signature

export declare const layerKeyValueStore: Layer.Layer<BackingPersistence, never, KeyValueStore.KeyValueStore>

Added in v1.0.0

layerMemory

Signature

export declare const layerMemory: Layer.Layer<BackingPersistence>

Added in v1.0.0

layerResult

Signature

export declare const layerResult: any

Added in v1.0.0

layerResultKeyValueStore

Signature

export declare const layerResultKeyValueStore: Layer.Layer<ResultPersistence, never, KeyValueStore.KeyValueStore>

Added in v1.0.0

layerResultMemory

Signature

export declare const layerResultMemory: Layer.Layer<ResultPersistence>

Added in v1.0.0

models

BackingPersistence (interface)

Signature

export interface BackingPersistence {
  readonly [BackingPersistenceTypeId]: BackingPersistenceTypeId
  readonly make: (storeId: string) => Effect.Effect<BackingPersistenceStore, never, Scope.Scope>
}

Added in v1.0.0

BackingPersistenceStore (interface)

Signature

export interface BackingPersistenceStore {
  readonly get: (key: string) => Effect.Effect<Option.Option<unknown>, PersistenceError>
  readonly getMany: (key: Array<string>) => Effect.Effect<Array<Option.Option<unknown>>, PersistenceError>
  readonly set: (
    key: string,
    value: unknown,
    ttl: Option.Option<Duration.Duration>
  ) => Effect.Effect<void, PersistenceError>
  readonly remove: (key: string) => Effect.Effect<void, PersistenceError>
  readonly clear: Effect.Effect<void, PersistenceError>
}

Added in v1.0.0

ResultPersistence (interface)

Signature

export interface ResultPersistence {
  readonly [ResultPersistenceTypeId]: ResultPersistenceTypeId
  readonly make: (options: {
    readonly storeId: string
    readonly timeToLive?: (key: ResultPersistence.KeyAny, exit: Exit.Exit<unknown, unknown>) => Duration.DurationInput
  }) => Effect.Effect<ResultPersistenceStore, never, Scope.Scope>
}

Added in v1.0.0

ResultPersistence (namespace)

Added in v1.0.0

Key (interface)

Signature

export interface Key<R, IE, E, IA, A> extends Schema.WithResult<A, IA, E, IE, R>, PrimaryKey.PrimaryKey {}

Added in v1.0.0

KeyAny (type alias)

Signature

export type KeyAny = Key<any, any, any, any, any> | Key<any, never, never, any, any>

Added in v1.0.0

TimeToLiveArgs (type alias)

Signature

export type TimeToLiveArgs<A> = A extends infer K
  ? K extends Key<infer _R, infer _IE, infer _E, infer _IA, infer _A>
    ? [request: K, exit: Exit.Exit<_A, _E>]
    : never
  : never

Added in v1.0.0

ResultPersistenceStore (interface)

Signature

export interface ResultPersistenceStore {
  readonly get: <R, IE, E, IA, A>(
    key: ResultPersistence.Key<R, IE, E, IA, A>
  ) => Effect.Effect<Option.Option<Exit.Exit<A, E>>, PersistenceError, R>
  readonly getMany: <R, IE, E, IA, A>(
    key: ReadonlyArray<ResultPersistence.Key<R, IE, E, IA, A>>
  ) => Effect.Effect<Array<Option.Option<Exit.Exit<A, E>>>, PersistenceError, R>
  readonly set: <R, IE, E, IA, A>(
    key: ResultPersistence.Key<R, IE, E, IA, A>,
    value: Exit.Exit<A, E>
  ) => Effect.Effect<void, PersistenceError, R>
  readonly remove: <R, IE, E, IA, A>(
    key: ResultPersistence.Key<R, IE, E, IA, A>
  ) => Effect.Effect<void, PersistenceError>
  readonly clear: Effect.Effect<void, PersistenceError>
}

Added in v1.0.0

tags

BackingPersistence

Signature

export declare const BackingPersistence: Context.Tag<BackingPersistence, BackingPersistence>

Added in v1.0.0

ResultPersistence

Signature

export declare const ResultPersistence: Context.Tag<ResultPersistence, ResultPersistence>

Added in v1.0.0

type ids

BackingPersistenceTypeId

Signature

export declare const BackingPersistenceTypeId: typeof BackingPersistenceTypeId

Added in v1.0.0

BackingPersistenceTypeId (type alias)

Signature

export type BackingPersistenceTypeId = typeof BackingPersistenceTypeId

Added in v1.0.0

ErrorTypeId

Signature

export declare const ErrorTypeId: typeof ErrorTypeId

Added in v1.0.0

ErrorTypeId (type alias)

Signature

export type ErrorTypeId = typeof ErrorTypeId

Added in v1.0.0

ResultPersistenceTypeId

Signature

export declare const ResultPersistenceTypeId: typeof ResultPersistenceTypeId

Added in v1.0.0

ResultPersistenceTypeId (type alias)

Signature

export type ResultPersistenceTypeId = typeof ResultPersistenceTypeId

Added in v1.0.0

utils

unsafeTtlToExpires

Signature

export declare const unsafeTtlToExpires: (clock: Clock.Clock, ttl: Option.Option<Duration.Duration>) => number | null

Added in v1.0.0