UNPKG

crewai-ts

Version:

TypeScript port of crewAI for agent-based workflows

99 lines 2.7 kB
/** * IncrementalMemoryLoader implementation * Provides efficient loading of large datasets with minimal memory pressure * by loading only what's needed when it's needed */ /** * Options for configuring IncrementalMemoryLoader behavior */ export interface IncrementalMemoryLoaderOptions<T> { /** * Page size for batch loading * @default 100 */ pageSize?: number; /** * Maximum number of pages to keep in memory * @default 10 */ maxCachedPages?: number; /** * Total number of items if known (allows for range validation) */ totalItems?: number; /** * Cache strategy: 'lru' keeps most recently used pages, 'window' keeps contiguous range * @default 'lru' */ cacheStrategy?: 'lru' | 'window'; /** * Optional key function to generate unique identifiers for items * If not provided, array indices will be used */ keyFn?: (item: T) => string; /** * Optional pre-processing function for loaded items */ processItem?: (item: T) => T; } /** * IncrementalMemoryLoader class * Implements efficient loading of large datasets with pagination and caching */ export declare class IncrementalMemoryLoader<T> { private fetchFn; private pageSize; private maxCachedPages; private cacheStrategy; private totalItems?; private keyFn?; private processItem?; private pageCache; private pageAccessOrder; private keyToLocationMap; private windowStart; private windowEnd; private stats; constructor(fetchFn: (offset: number, limit: number) => Promise<T[]>, options?: IncrementalMemoryLoaderOptions<T>); /** * Get an item by its index */ getItem(index: number): Promise<T | undefined>; /** * Get an item by its key (if keyFn was provided) */ getItemByKey(key: string): Promise<T | undefined>; /** * Get a page of items by page index */ getPage(pageIndex: number): Promise<T[]>; /** * Get a range of items */ getRange(startIndex: number, endIndex: number): Promise<T[]>; /** * Reset the loader state and clear caches */ reset(): void; /** * Get loader statistics */ getStats(): typeof this.stats; /** * Update the access order of pages (for LRU tracking) */ private updateAccessOrder; /** * Ensure the cache doesn't exceed maximum size by evicting pages */ private enforceMaxCacheSize; /** * Evict a page from the cache */ private evictPage; /** * Fetch items from the data source */ private fetchItems; } //# sourceMappingURL=IncrementalMemoryLoader.d.ts.map