/** * Cache dependency interface - similar to Yii2 cache dependency system * * A cache dependency represents a dependency relationship between cached data * and some external state. When the external state changes, the cached data * becomes invalid. * * @example * ```typescript * // Tag-based dependency * new TagDependency(['user-list']) * * // Database-based dependency * new DbDependency('SELECT MAX(updated_at) FROM users WHERE id = ?', [userId]) * * // Callback-based dependency * new CallbackDependency(() => ConfigService.get('app.version')) * ``` */ export interface CacheDependency { /** * Get a unique key that identifies this dependency * This key is used to store the dependency state * * @returns Unique dependency key */ getKey(): string; /** * Get the current state/value of this dependency * This value will be compared with stored state to detect changes * * @returns Current dependency data/state */ getData(): Promise; /** * Check if the dependency has changed by comparing old data with current data * * @param oldData - Previously stored dependency data * @returns true if dependency has changed, false otherwise */ isChanged(oldData: any): Promise; /** * Reset/clear the dependency state * Used when manually invalidating dependencies */ reset?(): Promise; } /** * Serialized dependency data stored alongside cached values */ export interface DependencyData { /** * Dependency key */ key: string; /** * Dependency state snapshot at cache time */ data: any; /** * Timestamp when dependency was captured */ timestamp: number; }