diff --git a/src/FilterLists.Api/V1/Controllers/BaseController.cs b/src/FilterLists.Api/V1/Controllers/BaseController.cs index bb0714d06..7f2e77a7a 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 MemoryCacheDurationDefault = TimeSpan.FromDays(1); + protected static readonly TimeSpan MemoryCacheSlidingExpirationDefault = TimeSpan.FromMinutes(5); protected readonly IMemoryCache MemoryCache; protected readonly SeedService SeedService; diff --git a/src/FilterLists.Api/V1/Controllers/DependentsController.cs b/src/FilterLists.Api/V1/Controllers/DependentsController.cs index 5e3fc787c..5470f6ffb 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 848446004..7d5b6dfcc 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 ee874696c..849325c9a 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return languageService.GetAllTargeted(); })); @@ -27,7 +27,7 @@ public async Task Index() => public async Task Seed() => Json(await MemoryCache.GetOrCreate("LanguagesController_Seed", entry => { - entry.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/LicensesController.cs b/src/FilterLists.Api/V1/Controllers/LicensesController.cs index 74b923b79..8dee8b852 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/ListsController.cs b/src/FilterLists.Api/V1/Controllers/ListsController.cs index 2661472d5..fdd0056b0 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs b/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs index b594521a3..0e9e9926b 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 abce0996c..5e9018129 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 6cd4fde76..3490af5ee 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 c3dde3429..474c5c2ca 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/MergesController.cs b/src/FilterLists.Api/V1/Controllers/MergesController.cs index 59013ffde..f56def8ad 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 4105c87dc..86c862e84 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return ruleService.GetCountAll(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/SoftwareController.cs b/src/FilterLists.Api/V1/Controllers/SoftwareController.cs index 72a389ee3..6635e74e7 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return softwareService.GetAll(); })); @@ -27,7 +27,7 @@ public async Task Index() => public async Task Seed() => Json(await MemoryCache.GetOrCreate("SoftwareController_Seed", entry => { - entry.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs b/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs index 2dfa41e85..bf300c51d 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; 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 b82325516..e5e53bb45 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); } diff --git a/src/FilterLists.Api/V1/Controllers/TagsController.cs b/src/FilterLists.Api/V1/Controllers/TagsController.cs index 5c75a0d07..a4e0a4b6d 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.AbsoluteExpirationRelativeToNow = MemoryCacheDurationDefault; + entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault; return SeedService.GetAllAsync(); })); }