layered-loader
Version:
Data loader with support for caching and fallback data sources
41 lines (40 loc) • 1.55 kB
TypeScript
import type { Redis } from 'ioredis';
import type { NotificationPublisher, PublisherErrorHandler } from '../notifications/NotificationPublisher';
import type { Logger } from '../util/Logger';
export type RedisPublisherConfig = {
serverUuid: string;
channel: string;
errorHandler?: PublisherErrorHandler;
logger?: Logger;
};
export type NotificationCommand = {
actionId: typeof CLEAR_COMMAND | typeof DELETE_COMMAND | typeof DELETE_MANY_COMMAND | typeof SET_COMMAND;
originUuid: string;
};
export type DeleteNotificationCommand = NotificationCommand & {
key: string;
};
export type SetNotificationCommand<T> = NotificationCommand & {
key: string;
value: T | null;
};
export type DeleteManyNotificationCommand = NotificationCommand & {
keys: string[];
};
export declare const CLEAR_COMMAND = "CLEAR";
export declare const DELETE_COMMAND = "DELETE";
export declare const DELETE_MANY_COMMAND = "DELETE_MANY";
export declare const SET_COMMAND = "SET";
export declare class RedisNotificationPublisher<LoadedValue> implements NotificationPublisher<LoadedValue> {
readonly channel: string;
readonly errorHandler: PublisherErrorHandler;
private readonly redis;
private readonly serverUuid;
constructor(redis: Redis, config: RedisPublisherConfig);
clear(): Promise<unknown>;
delete(key: string): Promise<unknown>;
set(key: string, value: LoadedValue | null): Promise<unknown>;
deleteMany(keys: string[]): Promise<unknown>;
close(): Promise<void>;
subscribe(): Promise<void>;
}