修复 缓存重复初始化

This commit is contained in:
🌌 2024-06-06 00:28:55 +08:00
parent 72ea0081d5
commit de4c47f45a
1 changed files with 7 additions and 9 deletions

View File

@ -259,24 +259,22 @@ export default class MysInfo {
*/
static async initCache (force = false, clearData = false) {
// 检查缓存标记
let cache = DailyCache.create()
if (!force && await cache.get('cache-ready')) {
const cache = DailyCache.create()
if (!force && await cache.get('cache-ready') || this.initing)
return true
}
this.initing = true
await DailyCache.clearOutdatedData()
if (clearData) {
if (clearData)
await MysUser.clearCache()
}
// 先初始化用户CK减少一些公共CK中ltuid无法识别的情况
await MysInfo.initUserCk()
await cache.set('cache-ready', new Date() * 1)
// 初始化公共ck
await MysInfo.initPubCk()
await cache.set('cache-ready', new Date() * 1)
delete this.initing
return true
}
@ -462,4 +460,4 @@ export default class MysInfo {
/** 统计次数设为超限 */
await this.ckUser.disable(game)
}
}
}