From 8fb8c888f554187fee01dc00e5f713f210b49cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Wed, 4 Dec 2024 19:48:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84uidCache=E5=92=8CuinCache=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/apis/user.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/core/apis/user.ts b/src/core/apis/user.ts index 34dd046b..5d8c7881 100644 --- a/src/core/apis/user.ts +++ b/src/core/apis/user.ts @@ -8,14 +8,10 @@ import { LRUCache } from '@/common/lru-cache'; export class NTQQUserApi { context: InstanceContext; core: NapCatCore; - private uidCache: LRUCache; - private uinCache: LRUCache; constructor(context: InstanceContext, core: NapCatCore) { this.context = context; this.core = core; - this.uidCache = new LRUCache(1000); - this.uinCache = new LRUCache(1000); } async getCoreAndBaseInfo(uids: string[]) { @@ -174,9 +170,6 @@ export class NTQQUserApi { } async getUidByUinV2(Uin: string) { - if (this.uidCache.get(Uin)) { - return this.uidCache.get(Uin); - } const services = [ () => this.context.session.getUixConvertService().getUid([Uin]).then((data) => data.uidInfo.get(Uin)).catch(() => undefined), () => promisify> @@ -188,7 +181,6 @@ export class NTQQUserApi { for (const service of services) { uid = await service(); if (uid && uid.indexOf('*') == -1 && uid !== '') { - this.uidCache.put(Uin, uid); break; } } @@ -196,9 +188,6 @@ export class NTQQUserApi { } async getUinByUidV2(Uid: string) { - if (this.uinCache.get(Uid)) { - return this.uinCache.get(Uid); - } const services = [ () => this.context.session.getUixConvertService().getUin([Uid]).then((data) => data.uinInfo.get(Uid)).catch(() => undefined), () => this.context.session.getGroupService().getUinByUids([Uid]).then((data) => data.uins.get(Uid)).catch(() => undefined), @@ -211,7 +200,6 @@ export class NTQQUserApi { for (const service of services) { uin = await service(); if (uin && uin !== '0' && uin !== '') { - this.uinCache.put(Uid, uin); break; } }