mastercache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
52 lines (49 loc) • 1.74 kB
TypeScript
import { Transport } from '@boringnode/bus/types/main';
import { LocalCache } from '../cache/facades/local-cache.js';
import { Logger } from 'typescript-log';
import { BusOptions, CacheBusMessage } from '../types/bus.js';
import { E as Emitter } from '../../events-CkqPK7En.js';
import '../cache/cache-entry/cache-entry.js';
import '../../mastercache-Di19srNZ.js';
import '../types/driver.js';
import '../types/provider.js';
import '../types/helpers.js';
import '../types/options/methods-options.js';
import '../types/options/options.js';
import '../types/options/drivers-options.js';
import 'knex';
import 'kysely';
import '@aws-sdk/client-dynamodb';
import 'ioredis';
import 'orchid-orm';
import '../cache/cache-entry/cache-entry-options.js';
/**
* The bus is used to notify other processes about cache changes.
* We use an underlying bus driver to send and receive messages.
*
* So basically, when a cache entry is set or deleted, we publish
* a message to the bus channel. Other processes are subscribed to
* the same channel and will receive the message and update their
* local cache accordingly.
*/
declare class Bus {
#private;
constructor(name: string, driver: Transport, logger: Logger, emitter: Emitter, options?: BusOptions);
/**
* Add a LocalCache for this bus to manage
* @param namespace The namespace
* @param cache The LocalCache instance
*/
manageCache(namespace: string, cache: LocalCache): void;
/**
* Publish a message to the bus channel
*
* @returns true if the message was published, false if not
*/
publish(message: CacheBusMessage): Promise<boolean>;
/**
* Disconnect the bus
*/
disconnect(): Promise<void>;
}
export { Bus };