Skip to content

Persistence

23 exports Added in v1.0.0 Source

Errors

Signature

declare class PersistenceBackingError extends any {
  constructor();
  message: any;
  static make(method: string, cause: unknown): PersistenceBackingError;
}

PersistenceError type

Added in v1.0.0 Source

Signature

type PersistenceError = PersistenceParseError | PersistenceBackingError;

Signature

declare class PersistenceParseError extends any {
  constructor();
  message: any;
  static make(method: string, error: ParseError): PersistenceParseError;
}

Layers

Signature

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

layerMemory

Added in v1.0.0 Source

Signature

declare const layerMemory: Layer.Layer<BackingPersistence>;

layerResult

Added in v1.0.0 Source

Signature

declare const layerResult: Layer<unknown, unknown, unknown>;

Signature

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

Signature

declare const layerResultMemory: Layer.Layer<ResultPersistence>;

Models

BackingPersistence interface

Added in v1.0.0 Source

Signature

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

BackingPersistenceStore interface

Added in v1.0.0 Source

Signature

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

Persistable interface

Added in v1.0.0 Source

Signature

interface Persistable<A extends Schema.Schema.Any, E extends Schema.Schema.All>
  extends
    WithResult<A["Type"], A["Encoded"], E["Type"], E["Encoded"], A["Context"] | E["Context"]>,
    PrimaryKey {}

ResultPersistence interface

Added in v1.0.0 Source

Signature

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

ResultPersistenceStore interface

Added in v1.0.0 Source

Signature

interface ResultPersistenceStore {
  readonly clear: Effect<void, PersistenceError>;
  readonly get: <R, IE, E, IA, A>(key: Key<R, IE, E, IA, A>) => Effect<Option<Exit<A, E>>, PersistenceError, R>;
  readonly getMany: <R, IE, E, IA, A>(key: readonly Array<Key<R, IE, E, IA, A>>) => Effect<Array<Option<Exit<A, E>>>, PersistenceError, R>;
  readonly remove: <R, IE, E, IA, A>(key: Key<R, IE, E, IA, A>) => Effect<void, PersistenceError>;
  readonly set: <R, IE, E, IA, A>(key: Key<R, IE, E, IA, A>, value: Exit<A, E>) => Effect<void, PersistenceError, R>;
  readonly setMany: <R, IE, E, IA, A>(entries: Iterable<readonly [Key<R, IE, E, IA, A>, Exit<A, E>]>) => Effect<void, PersistenceError, R>;
}

Other

Signature

declare function unsafeTtlToExpires(clock: Clock, ttl: Option<Duration>): number | null;

Tags

Signature

declare const BackingPersistence: Tag<BackingPersistence, BackingPersistence>;

Signature

declare const ResultPersistence: Tag<ResultPersistence, ResultPersistence>;

Type Ids

Signature

declare const BackingPersistenceTypeId: unique symbol;

Signature

type BackingPersistenceTypeId = typeof BackingPersistenceTypeId;

ErrorTypeId

Added in v1.0.0 Source

Signature

declare const ErrorTypeId: unique symbol;

ErrorTypeId type

Added in v1.0.0 Source

Signature

type ErrorTypeId = typeof ErrorTypeId;

Signature

declare const ResultPersistenceTypeId: unique symbol;

Signature

type ResultPersistenceTypeId = typeof ResultPersistenceTypeId;