mv3
This commit is contained in:
43
src/app/cache_key.ts
Normal file
43
src/app/cache_key.ts
Normal file
@ -0,0 +1,43 @@
|
||||
// 缓存key,所有缓存相关的key都需要定义在此
|
||||
// 使用装饰器维护缓存值
|
||||
import { ConfirmParam } from "@App/runtime/background/permission_verify";
|
||||
|
||||
export default class CacheKey {
|
||||
// 缓存触发器
|
||||
static Trigger(): (target: unknown, propertyName: string, descriptor: PropertyDescriptor) => void {
|
||||
return (target, propertyName, descriptor) => {
|
||||
descriptor.value();
|
||||
};
|
||||
}
|
||||
|
||||
// 脚本缓存
|
||||
static script(id: number): string {
|
||||
return `script:${id.toString()}`;
|
||||
}
|
||||
|
||||
// 加载脚本信息时的缓存,已处理删除
|
||||
static scriptInfo(uuid: string): string {
|
||||
return `scriptInfo:${uuid}`;
|
||||
}
|
||||
|
||||
// 脚本资源url缓存,可能存在泄漏
|
||||
static resourceByUrl(url: string): string {
|
||||
return `resource:${url}`;
|
||||
}
|
||||
|
||||
// 脚本value缓存,可能存在泄漏
|
||||
static scriptValue(id: number, storagename?: string[]): string {
|
||||
if (storagename) {
|
||||
return `value:storagename:${storagename[0]}`;
|
||||
}
|
||||
return `value:id:${id.toString()}`;
|
||||
}
|
||||
|
||||
static permissionConfirm(scriptId: number, confirm: ConfirmParam): string {
|
||||
return `permission:${scriptId.toString()}:${confirm.permissionValue || ""}:${confirm.permission || ""}`;
|
||||
}
|
||||
|
||||
static importInfo(uuid: string): string {
|
||||
return `import:${uuid}`;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user