mirror of
https://github.com/Jackett/Jackett
synced 2025-01-04 06:22:45 +00:00
core: improve search cache debug logs (#10502)
This commit is contained in:
parent
1d80aea02a
commit
b365607714
1 changed files with 18 additions and 6 deletions
|
@ -97,12 +97,17 @@ namespace Jackett.Common.Services
|
||||||
|
|
||||||
var trackerCache = _cache[indexer.Id];
|
var trackerCache = _cache[indexer.Id];
|
||||||
var queryHash = GetQueryHash(query);
|
var queryHash = GetQueryHash(query);
|
||||||
if (!trackerCache.Queries.ContainsKey(queryHash))
|
var cacheHit = trackerCache.Queries.ContainsKey(queryHash);
|
||||||
|
|
||||||
|
if (_logger.IsDebugEnabled)
|
||||||
|
_logger.Debug($"CACHE Search / Indexer: {trackerCache.TrackerId} / CacheHit: {cacheHit} / Query: {GetSerializedQuery(query)}");
|
||||||
|
|
||||||
|
if (!cacheHit)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var releases = trackerCache.Queries[queryHash].Results;
|
var releases = trackerCache.Queries[queryHash].Results;
|
||||||
_logger.Debug($"CACHE Search / Indexer: {trackerCache.TrackerId} / Found: {releases.Count} releases");
|
_logger.Debug($"CACHE Search Hit / Indexer: {trackerCache.TrackerId} / Found: {releases.Count} releases");
|
||||||
|
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,14 +236,21 @@ namespace Jackett.Common.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetQueryHash(TorznabQuery query)
|
private string GetQueryHash(TorznabQuery query)
|
||||||
|
{
|
||||||
|
var json = GetSerializedQuery(query);
|
||||||
|
// Compute the hash
|
||||||
|
return BitConverter.ToString(_sha256.ComputeHash(Encoding.ASCII.GetBytes(json)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetSerializedQuery(TorznabQuery query)
|
||||||
{
|
{
|
||||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(query);
|
var json = Newtonsoft.Json.JsonConvert.SerializeObject(query);
|
||||||
_logger.Debug($"CACHE Request query: {json}");
|
|
||||||
// Changes in the query to improve cache hits
|
// Changes in the query to improve cache hits
|
||||||
// Both request must return the same results, if not we are breaking Jackett search
|
// Both request must return the same results, if not we are breaking Jackett search
|
||||||
json = json.Replace("\"SearchTerm\":null", "\"SearchTerm\":\"\"");
|
json = json.Replace("\"SearchTerm\":null", "\"SearchTerm\":\"\"");
|
||||||
// Compute the hash
|
|
||||||
return BitConverter.ToString(_sha256.ComputeHash(Encoding.ASCII.GetBytes(json)));
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrintCacheStatus()
|
private void PrintCacheStatus()
|
||||||
|
|
Loading…
Reference in a new issue