import { CacheTaskStatusType } from './define'; import { PromiseCacher } from './promise-cacher'; /** * Represents a cache task that manages the lifecycle of a cached promise. * This class handles the execution, storage, and lifecycle management of asynchronous operations. * * @template OUTPUT - The type of the output value returned by the promise * @template INPUT - The type of the input key used to identify the cache entry */ export declare class CacheTask { private cacher; input: INPUT; private promiseHolder; /** The number of bytes used by the cached output value */ usedBytes: number; /** The number of times this cache entry has been accessed */ usedCount: number; /** Timestamp when this cache task was created */ createdAt: number; /** Timestamp when this cache task was last accessed */ lastAccessedAt: number; /** Timestamp when the async operation was resolved (success or error) */ resolvedAt: number; get order(): number; /** Timestamp when the fetch operation started */ get fetchStartedAt(): number; get queuedTime(): number; /** Response time in milliseconds (from fetch start to resolution) */ get responseTime(): number; /** Error that occurred during the async operation execution */ private taskError; /** * Creates a new cache task instance. * * @param cacher - The parent PromiseCacher instance that manages this task * @param input - The input key used to identify this cache entry * @param asyncOutput - The promise that will produce the cached output value */ constructor(cacher: PromiseCacher, input: INPUT, _asyncOutput?: Promise | OUTPUT | Error); run(): void; /** * Removes this cache task from the parent cacher. * This effectively deletes the cached entry. */ private release; private done; /** * Sets up promise handlers for the async operation lifecycle. * Manages success/error handling, memory tracking, and cleanup. * * When an operation completes successfully, calculates the memory usage. * For errors, applies the configured error policy (cache or release). * Always updates timing metrics and triggers cleanup when done. * * @private */ private setPromiseHandle; get isExpired(): boolean; /** * Gets the current status of this cache task. * Determines if the task is deprecated, active, or still awaiting completion. * * @returns The current status of the cache task */ get status(): CacheTaskStatusType; /** * Returns the cached output value or the promise that will resolve to it. * Updates access statistics and handles cloning if configured. * * @returns A promise that resolves to the cached output value * @throws {Error} If the task encountered an error during execution */ output(): Promise; /** * Calculates the cache score for this task using the configured scoring method. * This score is used to determine which cache entries should be evicted when memory limits are exceeded. * * @returns A numeric score representing the value/priority of this cache entry */ score(): number; }