mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
updates the package structure and updates initial horriblesubs scraper WIP
This commit is contained in:
19
lib/cache.js
19
lib/cache.js
@@ -11,6 +11,21 @@ const GLOBAL_TTL = process.env.METADATA_TTL || 7 * 24 * 60 * 60; // 7 days
|
||||
const MONGO_URI = process.env.MONGODB_URI;
|
||||
|
||||
const cache = initiateCache();
|
||||
const torrentFilesCache = initiateTorrentFilesCache();
|
||||
|
||||
function initiateTorrentFilesCache() {
|
||||
if (MONGO_URI) {
|
||||
return cacheManager.caching({
|
||||
store: mangodbStore,
|
||||
uri: MONGO_URI,
|
||||
options: {
|
||||
collection: 'cacheManager',
|
||||
},
|
||||
ttl: GLOBAL_TTL,
|
||||
ignoreCacheErrors: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initiateCache() {
|
||||
if (MONGO_URI) {
|
||||
@@ -18,7 +33,7 @@ function initiateCache() {
|
||||
store: mangodbStore,
|
||||
uri: MONGO_URI,
|
||||
options: {
|
||||
collection: 'cacheManager',
|
||||
collection: 'torrentio_scraper_collection',
|
||||
},
|
||||
ttl: GLOBAL_TTL,
|
||||
ignoreCacheErrors: true
|
||||
@@ -32,7 +47,7 @@ function initiateCache() {
|
||||
}
|
||||
|
||||
function retrieveTorrentFiles(infoHash) {
|
||||
return cache.get(`${TORRENT_FILES_KEY_PREFIX}:${infoHash}`)
|
||||
return torrentFilesCache.get(`${TORRENT_FILES_KEY_PREFIX}:${infoHash}`)
|
||||
.then((results) => {
|
||||
if (!results) {
|
||||
throw new Error('No cached files found');
|
||||
|
||||
Reference in New Issue
Block a user