cache resolve url in remote mongo and reduce cache time

This commit is contained in:
TheBeastLT
2024-01-31 09:24:31 +02:00
parent 11e86c3cdc
commit ebf2934c6c

View File

@@ -9,6 +9,7 @@ const RESOLVED_URL_KEY_PREFIX = `${GLOBAL_KEY_PREFIX}|resolved`;
const STREAM_TTL = process.env.STREAM_TTL || 24 * 60 * 60; // 24 hours
const STREAM_EMPTY_TTL = process.env.STREAM_EMPTY_TTL || 60; // 1 minute
const RESOLVED_URL_TTL = 3 * 60 * 60; // 3 hours
const AVAILABILITY_TTL = 8 * 60 * 60; // 8 hours
const AVAILABILITY_EMPTY_TTL = 30 * 60; // 30 minutes
const MESSAGE_VIDEO_URL_TTL = 60; // 1 minutes
@@ -30,7 +31,7 @@ function initiateRemoteCache() {
options: {
collection: 'torrentio_addon_collection',
socketTimeoutMS: 30000,
poolSize: 300,
poolSize: 200,
useNewUrlParser: true,
useUnifiedTopology: false,
ttl: STREAM_EMPTY_TTL
@@ -68,8 +69,8 @@ export function cacheWrapStream(id, method) {
}
export function cacheWrapResolvedUrl(id, method) {
return cacheWrap(memoryCache, `${RESOLVED_URL_KEY_PREFIX}:${id}`, method, {
ttl: (url) => isStaticUrl(url) ? MESSAGE_VIDEO_URL_TTL : STREAM_TTL
return cacheWrap(remoteCache, `${RESOLVED_URL_KEY_PREFIX}:${id}`, method, {
ttl: (url) => isStaticUrl(url) ? MESSAGE_VIDEO_URL_TTL : RESOLVED_URL_TTL
});
}