SqliteLiveImageStore.ts overview

A bounded live-image store using Effect's SQL and platform services.

Since v0.4.0


layers

layer

Reserve one SQLite connection and its exclusive lock for the Layer scope. The application supplies a dedicated SqlClient, FileSystem, Path, and Digest. Close the store before its client. The store releases its reservation and exclusive lock without closing the borrowed client.

Example

import * as SqliteLiveImageStore from "@effect-vfs/persistence/SqliteLiveImageStore"
import { ByteSize } from "effect"
 
const liveStore = SqliteLiveImageStore.layer({
  filename: "/var/lib/my-app/live.sqlite",
  maxImageBytes: ByteSize.megabytes(4),
  maxDatabaseBytes: ByteSize.megabytes(16)
})

Signature

declare const layer: (
  options: Options
) => Layer.Layer<
  LiveVolume.LiveImageStore,
  VfsError.ArgumentFailure | VfsError.StoreFailure,
  SqlClient | Digest.Digest | FileSystem.FileSystem | Path.Path
>

Source

Since v0.4.0

models

Options (interface)

Limits and the local database path used to verify the supplied SQL client. Supply a dedicated SQLite SqlClient for this same path.

Example

import type { Options } from "@effect-vfs/persistence/SqliteLiveImageStore"
import { ByteSize } from "effect"
 
const options: Options = {
  filename: "/var/lib/my-app/live.sqlite",
  maxImageBytes: ByteSize.megabytes(4),
  maxDatabaseBytes: ByteSize.megabytes(16)
}

Signature

export interface Options {
  readonly filename: string
  readonly maxImageBytes: ByteSize.ByteSize
  readonly maxDatabaseBytes: ByteSize.ByteSize
  readonly busyTimeoutMs?: number
  /**
   * Sync the containing directory after the supplied SQL client opens the
   * database. The implementation must report sync errors as failures.
   * Required before this store can be qualified for crash durability.
   */
  readonly syncDatabaseDirectory?: ((directory: string) => Effect.Effect<void, Error>) | undefined
}

Source

Since v0.4.0