mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
cache resolve url in remote mongo and reduce cache time
This commit is contained in:
@@ -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_TTL = process.env.STREAM_TTL || 24 * 60 * 60; // 24 hours
|
||||||
const STREAM_EMPTY_TTL = process.env.STREAM_EMPTY_TTL || 60; // 1 minute
|
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_TTL = 8 * 60 * 60; // 8 hours
|
||||||
const AVAILABILITY_EMPTY_TTL = 30 * 60; // 30 minutes
|
const AVAILABILITY_EMPTY_TTL = 30 * 60; // 30 minutes
|
||||||
const MESSAGE_VIDEO_URL_TTL = 60; // 1 minutes
|
const MESSAGE_VIDEO_URL_TTL = 60; // 1 minutes
|
||||||
@@ -30,7 +31,7 @@ function initiateRemoteCache() {
|
|||||||
options: {
|
options: {
|
||||||
collection: 'torrentio_addon_collection',
|
collection: 'torrentio_addon_collection',
|
||||||
socketTimeoutMS: 30000,
|
socketTimeoutMS: 30000,
|
||||||
poolSize: 300,
|
poolSize: 200,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: false,
|
useUnifiedTopology: false,
|
||||||
ttl: STREAM_EMPTY_TTL
|
ttl: STREAM_EMPTY_TTL
|
||||||
@@ -68,8 +69,8 @@ export function cacheWrapStream(id, method) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function cacheWrapResolvedUrl(id, method) {
|
export function cacheWrapResolvedUrl(id, method) {
|
||||||
return cacheWrap(memoryCache, `${RESOLVED_URL_KEY_PREFIX}:${id}`, method, {
|
return cacheWrap(remoteCache, `${RESOLVED_URL_KEY_PREFIX}:${id}`, method, {
|
||||||
ttl: (url) => isStaticUrl(url) ? MESSAGE_VIDEO_URL_TTL : STREAM_TTL
|
ttl: (url) => isStaticUrl(url) ? MESSAGE_VIDEO_URL_TTL : RESOLVED_URL_TTL
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user