Avoid initializing rbf cache in worker threads

This commit is contained in:
Mononaut 2023-08-03 18:09:00 +09:00
parent a509a52993
commit 20a8725450
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
2 changed files with 4 additions and 1 deletions

View File

@ -53,7 +53,7 @@ class RbfCache {
private expiring: Map<string, number> = new Map(); private expiring: Map<string, number> = new Map();
private cacheQueue: CacheEvent[] = []; private cacheQueue: CacheEvent[] = [];
constructor() { public init(): void {
setInterval(this.cleanup.bind(this), 1000 * 60 * 10); setInterval(this.cleanup.bind(this), 1000 * 60 * 10);
} }

View File

@ -43,6 +43,7 @@ import { AxiosError } from 'axios';
import v8 from 'v8'; import v8 from 'v8';
import { formatBytes, getBytesUnit } from './utils/format'; import { formatBytes, getBytesUnit } from './utils/format';
import redisCache from './api/redis-cache'; import redisCache from './api/redis-cache';
import rbfCache from './api/rbf-cache';
class Server { class Server {
private wss: WebSocket.Server | undefined; private wss: WebSocket.Server | undefined;
@ -107,6 +108,8 @@ class Server {
} }
} }
rbfCache.init();
this.app this.app
.use((req: Request, res: Response, next: NextFunction) => { .use((req: Request, res: Response, next: NextFunction) => {
res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Origin', '*');