Skip to content

@codesoul-co/hypha-memory / working-store

Using this module

Use the Working store module for persisting and reading data at this boundary. It exports 2 classes, 4 interfaces.

Import from the package entrypoint

ts
import {
  InMemoryWorkingMemoryStore,
  RedisWorkingMemoryStore,
} from '@codesoul-co/hypha-memory';

import type {
  RedisLikeWorkingMemoryClient,
  RedisWorkingMemoryStoreOptions,
  WorkingMemoryEntry,
  WorkingMemoryStore,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 4 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 2 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
InMemoryWorkingMemoryStoreclassnew InMemoryWorkingMemoryStore(now?: () => Date): InMemoryWorkingMemoryStoreIn Memory Working Memory Store class with 7 public constructor or member entries; its exact declarations are listed below.
RedisWorkingMemoryStoreclassnew RedisWorkingMemoryStore(options: RedisWorkingMemoryStoreOptions): RedisWorkingMemoryStoreRedis Working Memory Store class with 7 public constructor or member entries; its exact declarations are listed below.
RedisLikeWorkingMemoryClientinterfaceinterface RedisLikeWorkingMemoryClientRedis Like Working Memory Client interface with 5 public fields or methods.
RedisWorkingMemoryStoreOptionsinterfaceinterface RedisWorkingMemoryStoreOptionsRedis Working Memory Store Options interface with 7 public fields or methods.
WorkingMemoryEntryinterfaceinterface WorkingMemoryEntryWorking Memory Entry interface with 8 public fields or methods.
WorkingMemoryStoreinterfaceinterface WorkingMemoryStoreWorking Memory Store interface with 6 public fields or methods.

InMemoryWorkingMemoryStore

In Memory Working Memory Store class with 7 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryWorkingMemoryStore } from '@codesoul-co/hypha-memory';
  • Source module: working-store

Declaration

text
export declare class InMemoryWorkingMemoryStore implements WorkingMemoryStore {
    constructor(now?: () => Date);
    get<TValue = unknown>(scope: ManagedMemoryScope, id: string): Promise<WorkingMemoryEntry<TValue> | null>;
    set<TValue = unknown>(entry: Omit<WorkingMemoryEntry<TValue>, 'scopeHash'>, ttlSeconds?: number): Promise<WorkingMemoryEntry<TValue>>;
    delete(scope: ManagedMemoryScope, id: string): Promise<void>;
    list<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryEntry<TValue>>>;
    clearScope(scope: ManagedMemoryScope): Promise<void>;
    health(): Promise<ProviderHealth>;
}

Public members

MemberKindSignatureDescription
clearScopemethodclearScope(scope: ManagedMemoryScope): Promise<void>Public method; parameters and return type are shown in the signature.
constructorconstructor(now?: () => Date): InMemoryWorkingMemoryStoreCreates an instance of this class.
deletemethoddelete(scope: ManagedMemoryScope, id: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget<TValue = unknown>(scope: ManagedMemoryScope, id: string): Promise<WorkingMemoryEntry<TValue> | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
listmethodlist<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryEntry<TValue>>>Public method; parameters and return type are shown in the signature.
setmethodset<TValue = unknown>(entry: Omit<WorkingMemoryEntry<TValue>, "scopeHash">, ttlSeconds?: number): Promise<WorkingMemoryEntry<TValue>>Public method; parameters and return type are shown in the signature.

RedisWorkingMemoryStore

Redis Working Memory Store class with 7 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { RedisWorkingMemoryStore } from '@codesoul-co/hypha-memory';
  • Source module: working-store

Declaration

text
export declare class RedisWorkingMemoryStore implements WorkingMemoryStore {
    constructor(options: RedisWorkingMemoryStoreOptions);
    get<TValue = unknown>(scope: ManagedMemoryScope, id: string): Promise<WorkingMemoryEntry<TValue> | null>;
    set<TValue = unknown>(entry: Omit<WorkingMemoryEntry<TValue>, 'scopeHash'>, ttlSeconds?: number | undefined): Promise<WorkingMemoryEntry<TValue>>;
    delete(scope: ManagedMemoryScope, id: string): Promise<void>;
    list<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryEntry<TValue>>>;
    clearScope(scope: ManagedMemoryScope): Promise<void>;
    health(): Promise<ProviderHealth>;
}

Public members

MemberKindSignatureDescription
clearScopemethodclearScope(scope: ManagedMemoryScope): Promise<void>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: RedisWorkingMemoryStoreOptions): RedisWorkingMemoryStoreCreates an instance of this class.
deletemethoddelete(scope: ManagedMemoryScope, id: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget<TValue = unknown>(scope: ManagedMemoryScope, id: string): Promise<WorkingMemoryEntry<TValue> | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
listmethodlist<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryEntry<TValue>>>Public method; parameters and return type are shown in the signature.
setmethodset<TValue = unknown>(entry: Omit<WorkingMemoryEntry<TValue>, "scopeHash">, ttlSeconds?: number | undefined): Promise<WorkingMemoryEntry<TValue>>Public method; parameters and return type are shown in the signature.

RedisLikeWorkingMemoryClient

Redis Like Working Memory Client interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { RedisLikeWorkingMemoryClient } from '@codesoul-co/hypha-memory';
  • Source module: working-store

Declaration

text
export interface RedisLikeWorkingMemoryClient {
    get(key: string): Promise<string | null>;
    set(key: string, value: string, mode?: 'EX', durationSeconds?: number): Promise<unknown>;
    del(...keys: string[]): Promise<number>;
    scan(cursor: string, matchToken: 'MATCH', pattern: string, countToken: 'COUNT', count: number): Promise<[string, string[]]>;
    ping?(): Promise<string>;
}

Contract members

MemberKindSignatureDescription
delmethoddel(...keys: string[]): Promise<number>Public method; parameters and return type are shown in the signature.
getmethodget(key: string): Promise<string | null>Public method; parameters and return type are shown in the signature.
pingmethodping?(): Promise<string>Public method; parameters and return type are shown in the signature.
scanmethodscan(cursor: string, matchToken: "MATCH", pattern: string, countToken: "COUNT", count: number): Promise<[string, string[]]>Public method; parameters and return type are shown in the signature.
setmethodset(key: string, value: string, mode?: "EX", durationSeconds?: number): Promise<unknown>Public method; parameters and return type are shown in the signature.

RedisWorkingMemoryStoreOptions

Redis Working Memory Store Options interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { RedisWorkingMemoryStoreOptions } from '@codesoul-co/hypha-memory';
  • Source module: working-store

Declaration

text
export interface RedisWorkingMemoryStoreOptions {
    client: RedisLikeWorkingMemoryClient;
    namespace?: string;
    defaultTtlSeconds?: number;
    scanCount?: number;
    scanBudget?: Partial<Omit<RedisScanBudget, 'count'>>;
    now?: () => Date;
    nowMs?: () => number;
}

Contract members

MemberKindSignatureDescription
clientpropertyclient: RedisLikeWorkingMemoryClientPublic property; its type, readonly modifier and optionality are shown in the signature.
defaultTtlSecondspropertydefaultTtlSeconds?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
namespacepropertynamespace?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): DatePublic method; parameters and return type are shown in the signature.
nowMsmethodnowMs?(): numberPublic method; parameters and return type are shown in the signature.
scanBudgetpropertyscanBudget?: Partial<Omit<RedisScanBudget, "count">>Public property; its type, readonly modifier and optionality are shown in the signature.
scanCountpropertyscanCount?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

WorkingMemoryEntry

Working Memory Entry interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { WorkingMemoryEntry } from '@codesoul-co/hypha-memory';
  • Source module: working-store

Declaration

text
export interface WorkingMemoryEntry<TValue = unknown> {
    id: string;
    scope: ManagedMemoryScope;
    scopeHash: string;
    value: TValue;
    createdAt: string;
    updatedAt: string;
    expiresAt?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: ManagedMemoryScopePublic property; its type, readonly modifier and optionality are shown in the signature.
scopeHashpropertyscopeHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
updatedAtpropertyupdatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
valuepropertyvalue: TValuePublic property; its type, readonly modifier and optionality are shown in the signature.

WorkingMemoryStore

Working Memory Store interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { WorkingMemoryStore } from '@codesoul-co/hypha-memory';
  • Source module: working-store

Declaration

text
export interface WorkingMemoryStore {
    get<TValue = unknown>(scope: ManagedMemoryScope, id: string): Promise<WorkingMemoryEntry<TValue> | null>;
    set<TValue = unknown>(entry: Omit<WorkingMemoryEntry<TValue>, 'scopeHash'>, ttlSeconds?: number): Promise<WorkingMemoryEntry<TValue>>;
    delete(scope: ManagedMemoryScope, id: string): Promise<void>;
    list<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryEntry<TValue>>>;
    clearScope(scope: ManagedMemoryScope): Promise<void>;
    health(): Promise<ProviderHealth>;
}

Contract members

MemberKindSignatureDescription
clearScopemethodclearScope(scope: ManagedMemoryScope): Promise<void>Public method; parameters and return type are shown in the signature.
deletemethoddelete(scope: ManagedMemoryScope, id: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget<TValue = unknown>(scope: ManagedMemoryScope, id: string): Promise<WorkingMemoryEntry<TValue> | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
listmethodlist<TValue = unknown>(scope: ManagedMemoryScope): Promise<Array<WorkingMemoryEntry<TValue>>>Public method; parameters and return type are shown in the signature.
setmethodset<TValue = unknown>(entry: Omit<WorkingMemoryEntry<TValue>, "scopeHash">, ttlSeconds?: number): Promise<WorkingMemoryEntry<TValue>>Public method; parameters and return type are shown in the signature.