Cache time in HR & future cache bust function
This commit is contained in:
@@ -163,7 +163,7 @@ class Plex {
|
|||||||
.get(cacheKey)
|
.get(cacheKey)
|
||||||
.catch(() => fetch(url, options)) // else fetch fresh data
|
.catch(() => fetch(url, options)) // else fetch fresh data
|
||||||
.then(successfullResponse)
|
.then(successfullResponse)
|
||||||
.then(results => this.cache.set(cacheKey, results, 21600))
|
.then(results => this.cache.set(cacheKey, results, 21600)) // 6 hours
|
||||||
.then(this.mapResults)
|
.then(this.mapResults)
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -180,6 +180,28 @@ class Plex {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is not guarenteed to work, but if we see a movie or
|
||||||
|
// show has been imported, this function can be helpfull to call
|
||||||
|
// in order to try bust the cache preventing movieInfo and
|
||||||
|
// showInfo from seeing updates through existsInPlex.
|
||||||
|
bustSearchCacheWithTitle(title) {
|
||||||
|
const query = title;
|
||||||
|
const cacheKey = `${this.cacheTags.search}/${query}*`;
|
||||||
|
|
||||||
|
this.cache.del(
|
||||||
|
cacheKey,
|
||||||
|
(error,
|
||||||
|
response => {
|
||||||
|
if (response == 1) return true;
|
||||||
|
|
||||||
|
// TODO improve cache key matching by lowercasing it on the backend.
|
||||||
|
// what do we actually need to check for if the key was deleted or not
|
||||||
|
// it might be an error or another response code.
|
||||||
|
console.log("Unable to delete, key might not exists");
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
mapResults(response) {
|
mapResults(response) {
|
||||||
if (
|
if (
|
||||||
response == null ||
|
response == null ||
|
||||||
|
|||||||
Reference in New Issue
Block a user