Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 2x | import type {
ICoreCache,
ICoreClient,
ICoreKernel,
ICoreKernelModule,
ICorePresenter,
IDataBase,
} from '../lib';
import CoreElement from './CoreElement';
import type { IEntity } from './annotation';
/**
* Abstract base class that defines the API for cache implementations within the core framework.
*
* The cache is identified by a unique channel and module name. Concrete subclasses
* must provide the storage logic for all abstract methods.
*
* @template K - Type of the kernel that must extend {@link ICoreKernel}.
* @template T - Type of the database, which can be {@link IDataBase} or `null`.
* @template P - Type of the client, which can be {@link ICoreClient} or `null`.
* @template C - Type of the cache, which can be {@link ICoreCache} or `null`.
* @template E - Type of the presenter, which can be {@link ICorePresenter} or `null`.
*/
export default abstract class CoreCache<
K extends ICoreKernel<any> = ICoreKernel<any>,
T extends IDataBase<any, any> | null = any,
P extends ICoreClient | null = any,
C extends ICoreCache | null = any,
E extends ICorePresenter<any> | null = any,
>
extends CoreElement<K, T, P, C, E>
implements ICoreCache<K, T, P, C, E>
{
constructor(
channel: string,
module: ICoreKernelModule<any, any, any, any, any>,
) {
super(`cache-${channel}-${module.getName()}`, module);
}
abstract start(): Promise<void>;
abstract stop(): Promise<void>;
abstract set(key: string, val: string): Promise<void>;
abstract get(key: string): Promise<string | null>;
abstract delete(key: string): Promise<void>;
abstract clearAll(): Promise<void>;
abstract exist(key: string): Promise<boolean>;
abstract clearAllE(className: string): Promise<void>;
abstract deleteE(className: string, e_id: string): Promise<boolean>;
abstract getE<R extends IEntity>(
className: string,
e_id: string,
): Promise<R | null>;
abstract setE<R extends IEntity>(className: string, val: R): Promise<void>;
}
|