fix typeeror
This commit is contained in:
+6
-5
@@ -85,11 +85,12 @@ class LockManager {
|
|||||||
|
|
||||||
// 全局单例
|
// 全局单例
|
||||||
const globalKey = Symbol.for('__MOONTV_LOCK_MANAGER__');
|
const globalKey = Symbol.for('__MOONTV_LOCK_MANAGER__');
|
||||||
let lockManager: LockManager | undefined = (global as any)[globalKey];
|
let _lockManager: LockManager | undefined = (global as any)[globalKey];
|
||||||
|
|
||||||
if (!lockManager) {
|
if (!_lockManager) {
|
||||||
lockManager = new LockManager();
|
_lockManager = new LockManager();
|
||||||
(global as any)[globalKey] = lockManager;
|
(global as any)[globalKey] = _lockManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { lockManager };
|
// TypeScript doesn't recognize that lockManager is always defined after the if block
|
||||||
|
export const lockManager = _lockManager as LockManager;
|
||||||
|
|||||||
+13
-11
@@ -102,29 +102,31 @@ class OwnerExistenceCache {
|
|||||||
|
|
||||||
// 全局单例
|
// 全局单例
|
||||||
const globalKey = Symbol.for('__MOONTV_USER_INFO_CACHE__');
|
const globalKey = Symbol.for('__MOONTV_USER_INFO_CACHE__');
|
||||||
let userInfoCache: UserInfoCache | undefined = (global as any)[globalKey];
|
let _userInfoCache: UserInfoCache | undefined = (global as any)[globalKey];
|
||||||
|
|
||||||
if (!userInfoCache) {
|
if (!_userInfoCache) {
|
||||||
userInfoCache = new UserInfoCache();
|
_userInfoCache = new UserInfoCache();
|
||||||
(global as any)[globalKey] = userInfoCache;
|
(global as any)[globalKey] = _userInfoCache;
|
||||||
|
|
||||||
// 每分钟清理一次过期缓存
|
// 每分钟清理一次过期缓存
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
userInfoCache?.cleanup();
|
_userInfoCache?.cleanup();
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const userInfoCache = _userInfoCache as UserInfoCache;
|
||||||
|
|
||||||
const ownerExistenceGlobalKey = Symbol.for('__MOONTV_OWNER_EXISTENCE_CACHE__');
|
const ownerExistenceGlobalKey = Symbol.for('__MOONTV_OWNER_EXISTENCE_CACHE__');
|
||||||
let ownerExistenceCache: OwnerExistenceCache | undefined = (global as any)[ownerExistenceGlobalKey];
|
let _ownerExistenceCache: OwnerExistenceCache | undefined = (global as any)[ownerExistenceGlobalKey];
|
||||||
|
|
||||||
if (!ownerExistenceCache) {
|
if (!_ownerExistenceCache) {
|
||||||
ownerExistenceCache = new OwnerExistenceCache();
|
_ownerExistenceCache = new OwnerExistenceCache();
|
||||||
(global as any)[ownerExistenceGlobalKey] = ownerExistenceCache;
|
(global as any)[ownerExistenceGlobalKey] = _ownerExistenceCache;
|
||||||
|
|
||||||
// 每分钟清理一次过期缓存
|
// 每分钟清理一次过期缓存
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
ownerExistenceCache?.cleanup();
|
_ownerExistenceCache?.cleanup();
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { userInfoCache, ownerExistenceCache };
|
export const ownerExistenceCache = _ownerExistenceCache as OwnerExistenceCache;
|
||||||
|
|||||||
Reference in New Issue
Block a user