Skip to content

@codesoul-co/hypha-serving-cache / stores/redis-store

Using this module

Use the Redis store module for persisting and reading data at this boundary. It exports 1 class, 2 interfaces.

Import from the package entrypoint

ts
import {
  RedisCacheStore,
} from '@codesoul-co/hypha-serving-cache';

import type {
  RedisCacheClient,
  RedisCacheStoreOptions,
} from '@codesoul-co/hypha-serving-cache';

Usage patterns

  • Use the 2 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 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
RedisCacheStoreclassnew RedisCacheStore(options: RedisCacheStoreOptions): RedisCacheStoreRedis Cache Store class with 7 public constructor or member entries; its exact declarations are listed below.
RedisCacheClientinterfaceinterface RedisCacheClientRedis Cache Client interface with 6 public fields or methods.
RedisCacheStoreOptionsinterfaceinterface RedisCacheStoreOptionsRedis Cache Store Options interface with 4 public fields or methods.

RedisCacheStore

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

  • Kind: class
  • Import: import { RedisCacheStore } from '@codesoul-co/hypha-serving-cache';
  • Source module: stores/redis-store

Declaration

text
export declare class RedisCacheStore implements CacheStore {
    constructor(options: RedisCacheStoreOptions);
    get<T>(key: string): Promise<CacheEntry<T> | null>;
    set<T>(key: string, entry: CacheEntry<T>): Promise<void>;
    delete(key: string): Promise<void>;
    clear(): Promise<void>;
    health(): Promise<CacheStoreHealth>;
    close(): Promise<void>;
}

Public members

MemberKindSignatureDescription
clearmethodclear(): Promise<void>Public method; parameters and return type are shown in the signature.
closemethodclose(): Promise<void>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: RedisCacheStoreOptions): RedisCacheStoreCreates an instance of this class.
deletemethoddelete(key: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget<T>(key: string): Promise<CacheEntry<T> | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<CacheStoreHealth>Public method; parameters and return type are shown in the signature.
setmethodset<T>(key: string, entry: CacheEntry<T>): Promise<void>Public method; parameters and return type are shown in the signature.

RedisCacheClient

Redis Cache Client interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { RedisCacheClient } from '@codesoul-co/hypha-serving-cache';
  • Source module: stores/redis-store

Declaration

text
export interface RedisCacheClient {
    get(key: string): Promise<string | null>;
    set(key: string, value: string, ...args: Array<string | number>): Promise<unknown>;
    del(...keys: string[]): Promise<number>;
    scan(cursor: string, ...args: Array<string | number>): Promise<[string, string[]]>;
    ping?(): Promise<string>;
    quit?(): Promise<unknown>;
}

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.
quitmethodquit?(): Promise<unknown>Public method; parameters and return type are shown in the signature.
scanmethodscan(cursor: string, ...args: Array<string | number>): Promise<[string, string[]]>Public method; parameters and return type are shown in the signature.
setmethodset(key: string, value: string, ...args: Array<string | number>): Promise<unknown>Public method; parameters and return type are shown in the signature.

RedisCacheStoreOptions

Redis Cache Store Options interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { RedisCacheStoreOptions } from '@codesoul-co/hypha-serving-cache';
  • Source module: stores/redis-store

Declaration

text
export interface RedisCacheStoreOptions {
    client: RedisCacheClient;
    prefix?: string;
    closeClient?: boolean;
    now?: () => number;
}

Contract members

MemberKindSignatureDescription
clientpropertyclient: RedisCacheClientPublic property; its type, readonly modifier and optionality are shown in the signature.
closeClientpropertycloseClient?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): numberPublic method; parameters and return type are shown in the signature.
prefixpropertyprefix?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.