@bililive-tools/manager
Version:
Batch scheduling recorders
57 lines (56 loc) • 1.56 kB
TypeScript
/**
* Cache system for RecorderManager
* 提供统一的缓存接口用于处理持久化事务
*/
export interface CacheStore {
get<T = any>(key: string): Promise<T | undefined>;
set<T = any>(key: string, value: T, ttl?: number): Promise<void>;
delete(key: string): Promise<void>;
clear(): Promise<void>;
has(key: string): Promise<boolean>;
}
export interface RecorderCache {
/**
* 为每个录制器创建独立的命名空间
* @param recorderId 录制器 ID
*/
createNamespace(recorderId: string): NamespacedCache;
/**
* 获取全局缓存
*/
global(): NamespacedCache;
}
export interface NamespacedCache {
/**
* 通用的 key-value 存储
*/
get<T = any>(key: string): Promise<T | undefined>;
/**
* 通用的 key-value 存储
*/
set<T = any>(key: string, value: T): Promise<void>;
/**
* 删除指定 key
*/
delete(key: string): Promise<void>;
}
/**
* 内存缓存实现
*/
export declare class MemoryCacheStore implements CacheStore {
private store;
get<T = any>(key: string): Promise<T | undefined>;
set<T = any>(key: string, value: T, ttl?: number): Promise<void>;
delete(key: string): Promise<void>;
clear(): Promise<void>;
has(key: string): Promise<boolean>;
}
/**
* RecorderCache 实现
*/
export declare class RecorderCacheImpl implements RecorderCache {
private store;
constructor(store: CacheStore);
createNamespace(recorderId: string): NamespacedCache;
global(): NamespacedCache;
}