UNPKG

@imqueue/pg-cache

Version:

PostgreSQL managed cache on Redis for @imqueue-based service methods

43 lines (42 loc) 1.23 kB
import { FilteredChannels, PgCacheChannel } from './PgCache'; import { MethodDecorator } from './env'; export interface CacheWithOptions { /** * Time to live in milliseconds. By default is equivalent to 24 hours * * @type {number} */ ttl?: number; /** * PgBubSub channels to listen for invalidation. Usually channels are * table names. * * @type {string[] | FilteredChannels} */ channels: string[] | FilteredChannels; /** * Tag to use for this cache when set a value * * @type {string} */ tag?: string; } /** * Makes channel entry from a given channel name, class method name and options. * * @access private * @param {string} name * @param {string} method * @param {CacheWithOptions} options * @return {PgCacheChannel} */ export declare function makeChannel(name: string, method: string, options: CacheWithOptions): PgCacheChannel; /** * Decorator factory @cacheWith(CacheWithOptions) * This decorator should be used on a service methods, to set the caching * rules for a method. * * @param {CacheWithOptions} options * @return {MethodDecorator} */ export declare function cacheWith(options: CacheWithOptions): MethodDecorator;