mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
07d40cc339
commit
c776932e57
16 changed files with 21 additions and 24 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public DependentsController(IMemoryCache memoryCache, SeedService seedService) :
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("DependentsController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Dependent, DependentSeedDto>(typeof(Dependent).GetProperty("DependentFilterListId"),
|
||||
typeof(Dependent).GetProperty("DependencyFilterListId"));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public ForksController(IMemoryCache memoryCache, SeedService seedService) : base
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ForksController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Fork, ForkSeedDto>(typeof(Fork).GetProperty("UpstreamFilterListId"),
|
||||
typeof(Fork).GetProperty("ForkFilterListId"));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public LanguagesController(IMemoryCache memoryCache, SeedService seedService, La
|
|||
public async Task<IActionResult> Index() =>
|
||||
Json(await MemoryCache.GetOrCreate("LanguageService_Index", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return languageService.GetAllTargeted();
|
||||
}));
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public async Task<IActionResult> Index() =>
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("LanguagesController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Language, LanguageSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public LicensesController(IMemoryCache memoryCache, SeedService seedService) : b
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("LicensesController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<License, LicenseSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public ListsController(IMemoryCache memoryCache, SeedService seedService, Filter
|
|||
public async Task<IActionResult> Index() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsController_Index", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return filterListService.GetAllSummariesAsync();
|
||||
}));
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ public async Task<IActionResult> Index() =>
|
|||
public async Task<IActionResult> 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<IActionResult> GetById(int id) =>
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<FilterList, FilterListSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public ListsLanguagesController(IMemoryCache memoryCache, SeedService seedServic
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsLanguagesController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<FilterListLanguage, FilterListLanguageSeedDto>(
|
||||
typeof(FilterListLanguage).GetProperty("FilterListId"),
|
||||
typeof(FilterListLanguage).GetProperty("LanguageId"));
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public ListsMaintainersController(IMemoryCache memoryCache, SeedService seedServ
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsMaintainersController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<FilterListMaintainer, FilterListMaintainerSeedDto>(
|
||||
typeof(FilterListMaintainer).GetProperty("MaintainerId"),
|
||||
typeof(FilterListMaintainer).GetProperty("FilterListId"));
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public ListsTagsController(IMemoryCache memoryCache, SeedService seedService)
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsTagsController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<FilterListTag, FilterListTagSeedDto>(
|
||||
typeof(FilterListTag).GetProperty("FilterListId"),
|
||||
typeof(FilterListTag).GetProperty("TagId"));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public MaintainersController(IMemoryCache memoryCache, SeedService seedService)
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("MaintainersController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Maintainer, MaintainerSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public MergesController(IMemoryCache memoryCache, SeedService seedService) : bas
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("MergesController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Merge, MergeSeedDto>(typeof(Merge).GetProperty("MergeFilterListId"),
|
||||
typeof(Merge).GetProperty("UpstreamFilterListId"));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public RulesController(IMemoryCache memoryCache, RuleService ruleService) : base
|
|||
public async Task<IActionResult> Index() =>
|
||||
Json(await MemoryCache.GetOrCreate("RulesController_Index", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return ruleService.GetCountAll();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public SoftwareController(IMemoryCache memoryCache, SeedService seedService, Sof
|
|||
public async Task<IActionResult> Index() =>
|
||||
Json(await MemoryCache.GetOrCreate("SoftwareController_Index", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return softwareService.GetAll();
|
||||
}));
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public async Task<IActionResult> Index() =>
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("SoftwareController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Software, SoftwareSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public SoftwareSyntaxesController(IMemoryCache memoryCache, SeedService seedServ
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("SoftwareSyntaxesController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<SoftwareSyntax, SoftwareSyntaxSeedDto>(
|
||||
typeof(SoftwareSyntax).GetProperty("SyntaxId"), typeof(SoftwareSyntax).GetProperty("SoftwareId"));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public SyntaxesController(IMemoryCache memoryCache, SeedService seedService) : b
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("SyntaxesController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Syntax, SyntaxSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public TagsController(IMemoryCache memoryCache, SeedService seedService) : base(
|
|||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("TagsController_Seed", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = MemoryCacheSlidingExpirationDefault;
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return SeedService.GetAllAsync<Tag, TagSeedDto>();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue