KeyValueStore overview
Added in v1.0.0
Table of contents
combinators
prefix
Signature
export declare const prefix: {
(prefix: string): <S extends KeyValueStore.AnyStore>(self: S) => S
<S extends KeyValueStore.AnyStore>(self: S, prefix: string): S
}
Added in v1.0.0
constructors
make
Signature
export declare const make: (
impl: Omit<KeyValueStore, typeof TypeId | "has" | "modify" | "isEmpty" | "forSchema"> & Partial<KeyValueStore>
) => KeyValueStore
Added in v1.0.0
makeStringOnly
Signature
export 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
Added in v1.0.0
layers
layerFileSystem
Signature
export declare const layerFileSystem: (
directory: string
) => Layer.Layer<KeyValueStore, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>
Added in v1.0.0
layerMemory
Signature
export declare const layerMemory: Layer.Layer<KeyValueStore>
Added in v1.0.0
layerSchema
Signature
export declare const layerSchema: <A, I, R>(
schema: Schema.Schema<A, I, R>,
tagIdentifier: string
) => {
readonly tag: Context.Tag<SchemaStore<A, R>, SchemaStore<A, R>>
readonly layer: Layer.Layer<SchemaStore<A, R>, never, KeyValueStore>
}
Added in v1.0.0
layerStorage
Creates an KeyValueStorage from an instance of the Storage
api.
Signature
export declare const layerStorage: (evaluate: LazyArg<Storage>) => Layer.Layer<KeyValueStore>
Added in v1.0.0
models
KeyValueStore (interface)
Signature
export interface KeyValueStore {
readonly [TypeId]: TypeId
/**
* Returns the value of the specified key if it exists.
*/
readonly get: (key: string) => Effect.Effect<Option.Option<string>, PlatformError.PlatformError>
/**
* Returns the value of the specified key if it exists.
*/
readonly getUint8Array: (key: string) => Effect.Effect<Option.Option<Uint8Array>, PlatformError.PlatformError>
/**
* Sets the value of the specified key.
*/
readonly set: (key: string, value: string | Uint8Array) => Effect.Effect<void, PlatformError.PlatformError>
/**
* Removes the specified key.
*/
readonly remove: (key: string) => Effect.Effect<void, PlatformError.PlatformError>
/**
* Removes all entries.
*/
readonly clear: Effect.Effect<void, PlatformError.PlatformError>
/**
* Returns the number of entries.
*/
readonly size: Effect.Effect<number, PlatformError.PlatformError>
/**
* Updates the value of the specified key if it exists.
*/
readonly modify: (
key: string,
f: (value: string) => string
) => Effect.Effect<Option.Option<string>, PlatformError.PlatformError>
/**
* Updates the value of the specified key if it exists.
*/
readonly modifyUint8Array: (
key: string,
f: (value: Uint8Array) => Uint8Array
) => Effect.Effect<Option.Option<Uint8Array>, PlatformError.PlatformError>
/**
* Returns true if the KeyValueStore contains the specified key.
*/
readonly has: (key: string) => Effect.Effect<boolean, PlatformError.PlatformError>
/**
* Checks if the KeyValueStore contains any entries.
*/
readonly isEmpty: Effect.Effect<boolean, PlatformError.PlatformError>
/**
* Create a SchemaStore for the specified schema.
*/
readonly forSchema: <A, I, R>(schema: Schema.Schema<A, I, R>) => SchemaStore<A, R>
}
Added in v1.0.0
SchemaStore (interface)
Signature
export interface SchemaStore<A, R> {
readonly [SchemaStoreTypeId]: SchemaStoreTypeId
/**
* Returns the value of the specified key if it exists.
*/
readonly get: (
key: string
) => Effect.Effect<Option.Option<A>, PlatformError.PlatformError | ParseResult.ParseError, R>
/**
* Sets the value of the specified key.
*/
readonly set: (key: string, value: A) => Effect.Effect<void, PlatformError.PlatformError | ParseResult.ParseError, R>
/**
* Removes the specified key.
*/
readonly remove: (key: string) => Effect.Effect<void, PlatformError.PlatformError>
/**
* Removes all entries.
*/
readonly clear: Effect.Effect<void, PlatformError.PlatformError>
/**
* Returns the number of entries.
*/
readonly size: Effect.Effect<number, PlatformError.PlatformError>
/**
* Updates the value of the specified key if it exists.
*/
readonly modify: (
key: string,
f: (value: A) => A
) => Effect.Effect<Option.Option<A>, PlatformError.PlatformError | ParseResult.ParseError, R>
/**
* Returns true if the KeyValueStore contains the specified key.
*/
readonly has: (key: string) => Effect.Effect<boolean, PlatformError.PlatformError>
/**
* Checks if the KeyValueStore contains any entries.
*/
readonly isEmpty: Effect.Effect<boolean, PlatformError.PlatformError>
}
Added in v1.0.0
tags
KeyValueStore
Signature
export declare const KeyValueStore: Context.Tag<KeyValueStore, KeyValueStore>
Added in v1.0.0
type id
SchemaStoreTypeId
Signature
export declare const SchemaStoreTypeId: typeof SchemaStoreTypeId
Added in v1.0.0
SchemaStoreTypeId (type alias)
Signature
export type SchemaStoreTypeId = typeof SchemaStoreTypeId
Added in v1.0.0
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0
utils
KeyValueStore (namespace)
Added in v1.0.0
AnyStore (type alias)
Signature
export type AnyStore = KeyValueStore | SchemaStore<any, any>
Added in v1.0.0