UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

132 lines (131 loc) 3.65 kB
/** * @module Cache */ import { BaseEvent } from "../../event-bus/contracts/_module-exports.js"; import type { IFlexibleSerde } from "../../serde/contracts/_module-exports.js"; import { type OneOrMore, type TimeSpan } from "../../utilities/_module-exports.js"; /** * The event is dispatched when key is found. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{ key: string; value: TType; }> { } /** * The event is dispatched when key is not found. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyNotFoundCacheEvent extends BaseEvent<{ key: string; }> { } /** * The event is dispatched when key is added. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{ key: string; value: TType; ttl: TimeSpan | null; }> { } /** * The event is dispatched when key is updated. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{ key: string; value: TType; }> { } /** * The event is dispatched when key is removed. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyRemovedCacheEvent extends BaseEvent<{ key: string; }> { } /** * The event is dispatched when key is incremented. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyIncrementedCacheEvent extends BaseEvent<{ key: string; value: number; }> { } /** * The event is dispatched when key is decremented. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeyDecrementedCacheEvent extends BaseEvent<{ key: string; value: number; }> { } /** * The event is dispatched when all keys all cleared. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class KeysClearedCacheEvent extends BaseEvent<{}> { } /** * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare class UnexpectedErrorCacheEvent extends BaseEvent<{ keys?: string[]; value?: unknown; method: string; error: unknown; }> { } /** * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare const CACHE_EVENTS: { KeyFound: typeof KeyFoundCacheEvent; KeyNotFound: typeof KeyNotFoundCacheEvent; KeyAdded: typeof KeyAddedCacheEvent; KeyUpdated: typeof KeyUpdatedCacheEvent; KeyRemoved: typeof KeyRemovedCacheEvent; KeyIncremented: typeof KeyIncrementedCacheEvent; KeyDecremented: typeof KeyDecrementedCacheEvent; KeysCleared: typeof KeysClearedCacheEvent; UnexpectedError: typeof UnexpectedErrorCacheEvent; }; /** * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export type CacheEvents<TType = unknown> = KeyFoundCacheEvent<TType> | KeyNotFoundCacheEvent | KeyAddedCacheEvent<TType> | KeyUpdatedCacheEvent<TType> | KeyRemovedCacheEvent | KeyIncrementedCacheEvent | KeyDecrementedCacheEvent | KeysClearedCacheEvent | UnexpectedErrorCacheEvent; /** * The `registerCacheEventsToSerde` function registers all {@link ICache | `ICache`} related events with `IFlexibleSerde`, ensuring they will properly be serialized and deserialized. * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Events */ export declare function registerCacheEventsToSerde(serde: OneOrMore<IFlexibleSerde>): void;