mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
#114 start caching quality profiles. Set the cache on startup and when obtaining quality profiles in settings
This commit is contained in:
parent
08b14d0164
commit
e8c222f66e
6 changed files with 81 additions and 14 deletions
|
@ -126,7 +126,7 @@ namespace PlexRequests.UI.Modules
|
|||
}));
|
||||
|
||||
|
||||
|
||||
var mc = new MemoryCacheProvider();
|
||||
List<QualityModel> qualities = new List<QualityModel>();
|
||||
|
||||
if (isAdmin)
|
||||
|
@ -136,10 +136,13 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
taskList.Add(Task.Factory.StartNew(() =>
|
||||
{
|
||||
return CpApi.GetProfiles(cpSettings.FullUri, cpSettings.ApiKey).list.Select(x => new QualityModel() { Id = x._id, Name = x.label }); // TODO: cache this!
|
||||
return mc.GetOrSet(CacheKeys.CouchPotatoQualityProfiles, () =>
|
||||
{
|
||||
return CpApi.GetProfiles(cpSettings.FullUri, cpSettings.ApiKey); // TODO: cache this!
|
||||
});
|
||||
}).ContinueWith((t) =>
|
||||
{
|
||||
qualities = t.Result.ToList();
|
||||
qualities = t.Result.list.Select(x => new QualityModel() { Id = x._id, Name = x.label }).ToList();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +202,7 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
}));
|
||||
|
||||
var mc = new MemoryCacheProvider();
|
||||
List<QualityModel> qualities = new List<QualityModel>();
|
||||
if (isAdmin)
|
||||
{
|
||||
|
@ -207,25 +211,22 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
taskList.Add(Task.Factory.StartNew(() =>
|
||||
{
|
||||
return SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri).Select(x => new QualityModel() { Id = x.id.ToString(), Name = x.name }); // TODO: cache this!
|
||||
return mc.GetOrSet(CacheKeys.SonarrQualityProfiles, () =>
|
||||
{
|
||||
return SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri); // TODO: cache this!
|
||||
|
||||
});
|
||||
}).ContinueWith((t) =>
|
||||
{
|
||||
qualities = t.Result.ToList();
|
||||
qualities = t.Result.Select(x => new QualityModel() { Id = x.id.ToString(), Name = x.name }).ToList();
|
||||
}));
|
||||
}
|
||||
else {
|
||||
var sickRageSettings = SickRageSettings.GetSettings();
|
||||
if (sickRageSettings.Enabled)
|
||||
{
|
||||
taskList.Add(Task.Factory.StartNew(() =>
|
||||
{
|
||||
return sickRageSettings.Qualities.Select(x => new QualityModel() { Id = x.Key, Name = x.Value }); // TODO: cache this!
|
||||
}).ContinueWith((t) =>
|
||||
{
|
||||
qualities = t.Result.ToList();
|
||||
}));
|
||||
qualities = sickRageSettings.Qualities.Select(x => new QualityModel() { Id = x.Key, Name = x.Value }).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue