@nerjs/batchloader
Version:
`BatchLoader` is a tool for batching data requests with support for deduplication, caching, and parallel task management. It is designed to enhance flexibility and performance in scenarios requiring asynchronous data processing. This module was inspired b
32 lines (31 loc) • 1.17 kB
TypeScript
import { Key } from '../utils/interfaces';
import { ICache } from './interfaces';
export declare class StubCache implements ICache<any> {
get(_key: Key): Promise<any>;
set(_key: Key, _data: any): Promise<void>;
delete(_key: Key): Promise<void>;
clear(): Promise<void>;
}
/**
* Simple cache implementation based on Map.
* Designed for local in-memory usage.
* Methods are implemented with an asynchronous interface for compatibility
* with other cache types, such as external databases or distributed systems.
* Note that this implementation does not support TTL and relies on external
* mechanisms for managing data expiration.
*/
export declare class MapCache<T> implements ICache<T> {
private readonly map;
get(key: Key): Promise<T | undefined>;
set(key: Key, data: T): Promise<void>;
delete(key: Key): Promise<void>;
clear(): Promise<void>;
}
export declare class CacheAdapter<T> implements ICache<T> {
private readonly cache;
constructor(cache?: ICache<T>);
get(key: Key): Promise<T | undefined>;
set(key: Key, data: T): Promise<void>;
delete(key: Key): Promise<void>;
clear(): Promise<void>;
}