diff --git a/src/FilterLists.Api/V1/Controllers/BaseController.cs b/src/FilterLists.Api/V1/Controllers/BaseController.cs index 7f2e77a7a..98859df44 100644 --- a/src/FilterLists.Api/V1/Controllers/BaseController.cs +++ b/src/FilterLists.Api/V1/Controllers/BaseController.cs @@ -11,7 +11,7 @@ namespace FilterLists.Api.V1.Controllers [ResponseCache(Duration = 86400)] public class BaseController : Controller { - protected static readonly TimeSpan MemoryCacheSlidingExpirationDefault = TimeSpan.FromMinutes(5); + protected static readonly TimeSpan MemoryCacheExpirationDefault = TimeSpan.FromDays(1); protected readonly IMemoryCache MemoryCache; protected readonly SeedService SeedService; @@ -19,10 +19,7 @@ public BaseController() { } - protected BaseController(IMemoryCache memoryCache) - { - MemoryCache = memoryCache; - } + protected BaseController(IMemoryCache memoryCache) => MemoryCache = memoryCache; protected BaseController(IMemoryCache memoryCache, SeedService seedService) { diff --git a/src/FilterLists.Api/V1/Controllers/DependentsController.cs b/src/FilterLists.Api/V1/Controllers/DependentsController.cs index 5470f6ffb..4f4fca31a 100644 --- a/src/FilterLists.Api/V1/Controllers/DependentsController.cs +++ b/src/FilterLists.Api/V1/Controllers/DependentsController.cs @@ -17,7 +17,7 @@ public DependentsController(IMemoryCache memoryCache, SeedService seedService) : public async Task Seed() => Json(await MemoryCache.GetOrCreate("DependentsController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(typeof(Dependent).GetProperty("DependentFilterListId"), typeof(Dependent).GetProperty("DependencyFilterListId")); })); diff --git a/src/FilterLists.Api/V1/Controllers/ForksController.cs b/src/FilterLists.Api/V1/Controllers/ForksController.cs index 7d5b6dfcc..13a0d8c03 100644 --- a/src/FilterLists.Api/V1/Controllers/ForksController.cs +++ b/src/FilterLists.Api/V1/Controllers/ForksController.cs @@ -17,7 +17,7 @@ public ForksController(IMemoryCache memoryCache, SeedService seedService) : base public async Task Seed() => Json(await MemoryCache.GetOrCreate("ForksController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(typeof(Fork).GetProperty("UpstreamFilterListId"), typeof(Fork).GetProperty("ForkFilterListId")); })); diff --git a/src/FilterLists.Api/V1/Controllers/LanguagesController.cs b/src/FilterLists.Api/V1/Controllers/LanguagesController.cs index 849325c9a..29782a8f9 100644 --- a/src/FilterLists.Api/V1/Controllers/LanguagesController.cs +++ b/src/FilterLists.Api/V1/Controllers/LanguagesController.cs @@ -19,7 +19,7 @@ public LanguagesController(IMemoryCache memoryCache, SeedService seedService, La public async Task Index() => Json(await MemoryCache.GetOrCreate("LanguageService_Index", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return languageService.GetAllTargeted(); })); @@ -27,7 +27,7 @@ public async Task Index() => public async Task Seed() => Json(await MemoryCache.GetOrCreate("LanguagesController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/LicensesController.cs b/src/FilterLists.Api/V1/Controllers/LicensesController.cs index 8dee8b852..64d8a3d53 100644 --- a/src/FilterLists.Api/V1/Controllers/LicensesController.cs +++ b/src/FilterLists.Api/V1/Controllers/LicensesController.cs @@ -17,7 +17,7 @@ public LicensesController(IMemoryCache memoryCache, SeedService seedService) : b public async Task Seed() => Json(await MemoryCache.GetOrCreate("LicensesController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/ListsController.cs b/src/FilterLists.Api/V1/Controllers/ListsController.cs index fdd0056b0..4d79e654a 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsController.cs @@ -19,7 +19,7 @@ public ListsController(IMemoryCache memoryCache, SeedService seedService, Filter public async Task Index() => Json(await MemoryCache.GetOrCreate("ListsController_Index", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return filterListService.GetAllSummariesAsync(); })); @@ -29,7 +29,7 @@ public async Task Index() => public async Task GetById(int id) => Json(await MemoryCache.GetOrCreate("ListsController_GetById_" + id, entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return filterListService.GetDetailsAsync((uint)id); })); @@ -37,7 +37,7 @@ public async Task GetById(int id) => public async Task Seed() => Json(await MemoryCache.GetOrCreate("ListsController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs b/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs index 0e9e9926b..7ff794ff7 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs @@ -18,7 +18,7 @@ public ListsLanguagesController(IMemoryCache memoryCache, SeedService seedServic public async Task Seed() => Json(await MemoryCache.GetOrCreate("ListsLanguagesController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync( typeof(FilterListLanguage).GetProperty("FilterListId"), typeof(FilterListLanguage).GetProperty("LanguageId")); diff --git a/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs b/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs index 5e9018129..1e4fcb83e 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs @@ -18,7 +18,7 @@ public ListsMaintainersController(IMemoryCache memoryCache, SeedService seedServ public async Task Seed() => Json(await MemoryCache.GetOrCreate("ListsMaintainersController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync( typeof(FilterListMaintainer).GetProperty("MaintainerId"), typeof(FilterListMaintainer).GetProperty("FilterListId")); diff --git a/src/FilterLists.Api/V1/Controllers/ListsTagsController.cs b/src/FilterLists.Api/V1/Controllers/ListsTagsController.cs index 3490af5ee..688552788 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsTagsController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsTagsController.cs @@ -18,7 +18,7 @@ public ListsTagsController(IMemoryCache memoryCache, SeedService seedService) public async Task Seed() => Json(await MemoryCache.GetOrCreate("ListsTagsController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync( typeof(FilterListTag).GetProperty("FilterListId"), typeof(FilterListTag).GetProperty("TagId")); diff --git a/src/FilterLists.Api/V1/Controllers/MaintainersController.cs b/src/FilterLists.Api/V1/Controllers/MaintainersController.cs index 474c5c2ca..392ae8e78 100644 --- a/src/FilterLists.Api/V1/Controllers/MaintainersController.cs +++ b/src/FilterLists.Api/V1/Controllers/MaintainersController.cs @@ -17,7 +17,7 @@ public MaintainersController(IMemoryCache memoryCache, SeedService seedService) public async Task Seed() => Json(await MemoryCache.GetOrCreate("MaintainersController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/MergesController.cs b/src/FilterLists.Api/V1/Controllers/MergesController.cs index f56def8ad..133f230b0 100644 --- a/src/FilterLists.Api/V1/Controllers/MergesController.cs +++ b/src/FilterLists.Api/V1/Controllers/MergesController.cs @@ -17,7 +17,7 @@ public MergesController(IMemoryCache memoryCache, SeedService seedService) : bas public async Task Seed() => Json(await MemoryCache.GetOrCreate("MergesController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(typeof(Merge).GetProperty("MergeFilterListId"), typeof(Merge).GetProperty("UpstreamFilterListId")); })); diff --git a/src/FilterLists.Api/V1/Controllers/RulesController.cs b/src/FilterLists.Api/V1/Controllers/RulesController.cs index 86c862e84..bba815c30 100644 --- a/src/FilterLists.Api/V1/Controllers/RulesController.cs +++ b/src/FilterLists.Api/V1/Controllers/RulesController.cs @@ -16,7 +16,7 @@ public RulesController(IMemoryCache memoryCache, RuleService ruleService) : base public async Task Index() => Json(await MemoryCache.GetOrCreate("RulesController_Index", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return ruleService.GetCountAll(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/SoftwareController.cs b/src/FilterLists.Api/V1/Controllers/SoftwareController.cs index 6635e74e7..b79630890 100644 --- a/src/FilterLists.Api/V1/Controllers/SoftwareController.cs +++ b/src/FilterLists.Api/V1/Controllers/SoftwareController.cs @@ -19,7 +19,7 @@ public SoftwareController(IMemoryCache memoryCache, SeedService seedService, Sof public async Task Index() => Json(await MemoryCache.GetOrCreate("SoftwareController_Index", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return softwareService.GetAll(); })); @@ -27,7 +27,7 @@ public async Task Index() => public async Task Seed() => Json(await MemoryCache.GetOrCreate("SoftwareController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs b/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs index bf300c51d..69ec8a6e4 100644 --- a/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs +++ b/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs @@ -18,7 +18,7 @@ public SoftwareSyntaxesController(IMemoryCache memoryCache, SeedService seedServ public async Task Seed() => Json(await MemoryCache.GetOrCreate("SoftwareSyntaxesController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync( typeof(SoftwareSyntax).GetProperty("SyntaxId"), typeof(SoftwareSyntax).GetProperty("SoftwareId")); })); diff --git a/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs b/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs index e5e53bb45..6a03a24ad 100644 --- a/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs +++ b/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs @@ -17,7 +17,7 @@ public SyntaxesController(IMemoryCache memoryCache, SeedService seedService) : b public async Task Seed() => Json(await MemoryCache.GetOrCreate("SyntaxesController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/TagsController.cs b/src/FilterLists.Api/V1/Controllers/TagsController.cs index a4e0a4b6d..b34a305f0 100644 --- a/src/FilterLists.Api/V1/Controllers/TagsController.cs +++ b/src/FilterLists.Api/V1/Controllers/TagsController.cs @@ -17,7 +17,7 @@ public TagsController(IMemoryCache memoryCache, SeedService seedService) : base( public async Task Seed() => Json(await MemoryCache.GetOrCreate("TagsController_Seed", entry => { - entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; + entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault; return SeedService.GetAllAsync(); })); }