diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 15:27:08 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-22 15:27:08 +0900 |
| commit | 52d577c7dd7bf87b3fae34f539bb6e656c7c0ed2 (patch) | |
| tree | 9805c625a7fba9d8631db8a92772b2772d8632ec /src/queue/processors | |
| parent | Merge branch 'develop' (diff) | |
| parent | 12.75.0 (diff) | |
| download | misskey-52d577c7dd7bf87b3fae34f539bb6e656c7c0ed2.tar.gz misskey-52d577c7dd7bf87b3fae34f539bb6e656c7c0ed2.tar.bz2 misskey-52d577c7dd7bf87b3fae34f539bb6e656c7c0ed2.zip | |
Merge branch 'develop'
Diffstat (limited to 'src/queue/processors')
| -rw-r--r-- | src/queue/processors/deliver.ts | 19 | ||||
| -rw-r--r-- | src/queue/processors/inbox.ts | 1 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/queue/processors/deliver.ts b/src/queue/processors/deliver.ts index cb7587ef81..a8b4ed4fe3 100644 --- a/src/queue/processors/deliver.ts +++ b/src/queue/processors/deliver.ts @@ -7,11 +7,15 @@ import { instanceChart } from '../../services/chart'; import { fetchInstanceMetadata } from '../../services/fetch-instance-metadata'; import { fetchMeta } from '../../misc/fetch-meta'; import { toPuny } from '../../misc/convert-host'; +import { Cache } from '../../misc/cache'; +import { Instance } from '../../models/entities/instance'; const logger = new Logger('deliver'); let latest: string | null = null; +const suspendedHostsCache = new Cache<Instance[]>(1000 * 60 * 60); + export default async (job: Bull.Job) => { const { host } = new URL(job.data.to); @@ -22,12 +26,15 @@ export default async (job: Bull.Job) => { } // isSuspendedなら中断 - const suspendedHosts = await Instances.find({ - where: { - isSuspended: true - }, - cache: 60 * 1000 - }); + let suspendedHosts = suspendedHostsCache.get(null); + if (suspendedHosts == null) { + suspendedHosts = await Instances.find({ + where: { + isSuspended: true + }, + }); + suspendedHostsCache.set(null, suspendedHosts); + } if (suspendedHosts.map(x => x.host).includes(toPuny(host))) { return 'skip (suspended)'; } diff --git a/src/queue/processors/inbox.ts b/src/queue/processors/inbox.ts index b4e8b85a46..a5822ff25f 100644 --- a/src/queue/processors/inbox.ts +++ b/src/queue/processors/inbox.ts @@ -40,6 +40,7 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => { return `Old keyId is no longer supported. ${keyIdLower}`; } + // TDOO: キャッシュ const dbResolver = new DbResolver(); // HTTP-Signature keyIdを元にDBから取得 |