core: redo search cache from scratch. resolves #10382 (#10447)

In simple words, when you make a request in Jackett, the results are saved in memory (cache). The next request will return results form the cache improving response time and making fewer requests to the sites.
* We assume all indexers/sites are stateless, the same request return the same response. If you change the search term, categories or something in the query Jackett has to make a live request to the indexer.
* There are some situations when we don't want to use the cache:
** When we are testing the indexers => if query.IsTest results are not cached
** When the user updates the configuration of one indexer => We call CleanIndexerCache to remove cached results before testing the configuration
** When there is some error/exception in the indexer => The results are not cached so we can retry in the next request
* We want to limit the memory usage, so we try to remove elements from cache ASAP:
** Each indexer can have a maximum number of results in memory. If the limit is exceeded we remove old results
** Cached results expire after some time
* Users can configure the cache or even disable it
This commit is contained in:
Diego Heras
2020-12-11 23:14:21 +01:00
committed by GitHub
parent ec3787e803
commit 69125add3e
126 changed files with 744 additions and 364 deletions

View File

@@ -25,7 +25,7 @@ namespace Jackett.Test.Common.Indexers
},
Search = new searchBlock()
};
var indexer = new CardigannIndexer(null, null, null, null, definition);
var indexer = new CardigannIndexer(null, null, null, null, null, definition);
Assert.True(indexer.TorznabCaps.SearchAvailable);
Assert.IsEmpty(indexer.TorznabCaps.TvSearchParams);
@@ -90,7 +90,7 @@ namespace Jackett.Test.Common.Indexers
},
Search = new searchBlock()
};
indexer = new CardigannIndexer(null, null, null, null, definition);
indexer = new CardigannIndexer(null, null, null, null, null, definition);
// test categories
var expected = new List<TorznabCategory>
@@ -125,7 +125,7 @@ namespace Jackett.Test.Common.Indexers
},
Search = new searchBlock()
};
indexer = new CardigannIndexer(null, null, null, null, definition);
indexer = new CardigannIndexer(null, null, null, null, null, definition);
Assert.True(indexer.TorznabCaps.SearchAvailable);
Assert.AreEqual(

View File

@@ -20,7 +20,8 @@ namespace Jackett.Test.Common.Models
configService: null,
logger: null,
configData: null,
p: null)
p: null,
cs: null)
{
}

View File

@@ -21,7 +21,8 @@ namespace Jackett.Test.TestHelpers
configService: null,
logger: null,
configData: new ConfigurationData(),
p: null)
p: null,
cacheService: null)
{
Encoding = Encoding.UTF8;
Language = "en-us";