Skip to content
Effect Days 2026 Get your ticket

KeyValueStore

15 exports Added in v1.0.0 Source

Combinators

prefix

Added in v1.0.0 Source

Signature

declare const prefix: {
(prefix: string): <S extends AnyStore>(self: S) => S;
<S extends AnyStore>(self: S, prefix: string): S;
}

Constructors

make

Added in v1.0.0 Source

Signature

declare const make: (impl: Omit<KeyValueStore, typeof TypeId | "has" | "modify" | "modifyUint8Array" | "isEmpty" | "forSchema"> & Partial<KeyValueStore>) => KeyValueStore

Signature

declare const makeStringOnly: (impl: Pick<KeyValueStore, "get" | "remove" | "clear" | "size"> & Partial<Omit<KeyValueStore, "set">> & {
readonly set: (key: string, value: string) => Effect.Effect<void, PlatformError.PlatformError>;
}) => KeyValueStore

Layers

Provides a file-backed key-value store in the specified directory.

Keys are percent-encoded as single file names. Empty keys, . and .. are rejected. Keys are only guaranteed to be distinct on case-sensitive file systems.

clear removes the directory recursively, so it must not be shared with unrelated data.

Signature

declare const layerFileSystem: (directory: string) => Layer.Layer<KeyValueStore, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>

layerMemory

Added in v1.0.0 Source

Signature

declare const layerMemory: Layer.Layer<KeyValueStore>

layerSchema

Added in v1.0.0 Source

Signature

declare const layerSchema: <A, I, R>(schema: Schema.Schema<A, I, R>, tagIdentifier: string) => {
readonly layer: Layer.Layer<SchemaStore<A, R>, never, KeyValueStore>;
readonly tag: Context.Tag<SchemaStore<A, R>, SchemaStore<A, R>>;
}

layerStorage

Added in v1.0.0 Source

Creates an KeyValueStorage from an instance of the Storage api.

See

Signature

declare const layerStorage: (evaluate: LazyArg<Storage>) => Layer.Layer<KeyValueStore>

Models

KeyValueStore interface

Added in v1.0.0 Source

Signature

interface KeyValueStore {
readonly [TypeId]: typeof TypeId;
readonly clear: Effect<void, PlatformError>;
readonly forSchema: <A, I, R>(schema: any) => SchemaStore<A, R>;
readonly get: (key: string) => Effect<Option<string>, PlatformError>;
readonly getUint8Array: (key: string) => Effect<Option<Uint8Array<ArrayBufferLike>>, PlatformError>;
readonly has: (key: string) => Effect<boolean, PlatformError>;
readonly isEmpty: Effect<boolean, PlatformError>;
readonly modify: (key: string, f: (value: string) => string) => Effect<Option<string>, PlatformError>;
readonly modifyUint8Array: (key: string, f: (value: Uint8Array) => Uint8Array) => Effect<Option<Uint8Array<ArrayBufferLike>>, PlatformError>;
readonly remove: (key: string) => Effect<void, PlatformError>;
readonly set: (key: string, value: string | Uint8Array<ArrayBufferLike>) => Effect<void, PlatformError>;
readonly size: Effect<number, PlatformError>;
}

SchemaStore interface

Added in v1.0.0 Source

Signature

interface SchemaStore<A, R> {
readonly [SchemaStoreTypeId]: typeof SchemaStoreTypeId;
readonly clear: Effect<void, PlatformError>;
readonly get: (key: string) => Effect<Option<A>, any, R>;
readonly has: (key: string) => Effect<boolean, PlatformError>;
readonly isEmpty: Effect<boolean, PlatformError>;
readonly modify: (key: string, f: (value: A) => A) => Effect<Option<A>, any, R>;
readonly remove: (key: string) => Effect<void, PlatformError>;
readonly set: (key: string, value: A) => Effect<void, any, R>;
readonly size: Effect<number, PlatformError>;
}

Other

Tags

Signature

declare const KeyValueStore: Tag<KeyValueStore, KeyValueStore>

Type Id

Signature

declare const SchemaStoreTypeId: unique symbol

SchemaStoreTypeId type

Added in v1.0.0 Source

Signature

type SchemaStoreTypeId = typeof SchemaStoreTypeId

TypeId

Added in v1.0.0 Source

Signature

declare const TypeId: unique symbol

TypeId type

Added in v1.0.0 Source

Signature

type TypeId = typeof TypeId