mirror of
https://github.com/seerr-team/seerr.git
synced 2025-12-23 23:58:07 -05:00
27 lines
670 B
TypeScript
27 lines
670 B
TypeScript
import logger from '@server/logger';
|
|
import { DnsCacheManager } from 'dns-caching';
|
|
|
|
export let dnsCache: DnsCacheManager | undefined;
|
|
|
|
export function initializeDnsCache({
|
|
forceMinTtl,
|
|
forceMaxTtl,
|
|
}: {
|
|
forceMinTtl?: number;
|
|
forceMaxTtl?: number;
|
|
}) {
|
|
if (dnsCache) {
|
|
logger.warn('DNS Cache is already initialized', { label: 'DNS Cache' });
|
|
return;
|
|
}
|
|
|
|
logger.info('Initializing DNS Cache', { label: 'DNS Cache' });
|
|
|
|
dnsCache = new DnsCacheManager({
|
|
logger,
|
|
forceMinTtl: typeof forceMinTtl === 'number' ? forceMinTtl * 1000 : 0,
|
|
forceMaxTtl: typeof forceMaxTtl === 'number' ? forceMaxTtl * 1000 : -1,
|
|
});
|
|
dnsCache.initialize();
|
|
}
|