enhance(backend): improve cache
This commit is contained in:
@@ -7,7 +7,7 @@ import { MetaService } from '@/core/MetaService.js';
|
||||
import { ApRequestService } from '@/core/activitypub/ApRequestService.js';
|
||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
import { FetchInstanceMetadataService } from '@/core/FetchInstanceMetadataService.js';
|
||||
import { MemoryKVCache } from '@/misc/cache.js';
|
||||
import { MemoryCache } from '@/misc/cache.js';
|
||||
import type { Instance } from '@/models/entities/Instance.js';
|
||||
import InstanceChart from '@/core/chart/charts/instance.js';
|
||||
import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
||||
@@ -22,7 +22,7 @@ import type { DeliverJobData } from '../types.js';
|
||||
@Injectable()
|
||||
export class DeliverProcessorService {
|
||||
private logger: Logger;
|
||||
private suspendedHostsCache: MemoryKVCache<Instance[]>;
|
||||
private suspendedHostsCache: MemoryCache<Instance[]>;
|
||||
private latest: string | null;
|
||||
|
||||
constructor(
|
||||
@@ -46,7 +46,7 @@ export class DeliverProcessorService {
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('deliver');
|
||||
this.suspendedHostsCache = new MemoryKVCache<Instance[]>(1000 * 60 * 60);
|
||||
this.suspendedHostsCache = new MemoryCache<Instance[]>(1000 * 60 * 60);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
@@ -60,14 +60,14 @@ export class DeliverProcessorService {
|
||||
}
|
||||
|
||||
// isSuspendedなら中断
|
||||
let suspendedHosts = this.suspendedHostsCache.get(null);
|
||||
let suspendedHosts = this.suspendedHostsCache.get();
|
||||
if (suspendedHosts == null) {
|
||||
suspendedHosts = await this.instancesRepository.find({
|
||||
where: {
|
||||
isSuspended: true,
|
||||
},
|
||||
});
|
||||
this.suspendedHostsCache.set(null, suspendedHosts);
|
||||
this.suspendedHostsCache.set(suspendedHosts);
|
||||
}
|
||||
if (suspendedHosts.map(x => x.host).includes(this.utilityService.toPuny(host))) {
|
||||
return 'skip (suspended)';
|
||||
|
Reference in New Issue
Block a user