mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
strip out all caching for now (was leaking across endpoints)
This commit is contained in:
parent
df7967418d
commit
b2cc1a07f7
15 changed files with 36 additions and 139 deletions
|
|
@ -1,9 +0,0 @@
|
|||
// https://github.com/aspnet/Docs/blob/master/aspnetcore/performance/caching/memory/sample/WebCache/CacheKeys.cs
|
||||
|
||||
namespace FilterLists.Api
|
||||
{
|
||||
public static class CacheKeys
|
||||
{
|
||||
public static readonly string Entry = "_Entry";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
using System.IO;
|
||||
using Microsoft.ApplicationInsights.Extensibility.Implementation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
|
|
@ -11,26 +10,12 @@ public static class ConfigureServicesCollection
|
|||
{
|
||||
public static void AddFilterListsApi(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvcCustom();
|
||||
services.AddMvc();
|
||||
services.AddApiVersioning();
|
||||
services.AddResponseCaching();
|
||||
services.AddMemoryCache();
|
||||
services.AddSwaggerGenCustom();
|
||||
TelemetryDebugWriter.IsTracingDisabled = true;
|
||||
}
|
||||
|
||||
private static void AddMvcCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.CacheProfiles.Add("Long-Lived",
|
||||
new CacheProfile
|
||||
{
|
||||
Duration = 86400
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static void AddSwaggerGenCustom(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public void Configure(IApplicationBuilder app)
|
|||
{
|
||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
||||
});
|
||||
app.UseResponseCaching();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,19 +1,12 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Produces("application/json")]
|
||||
[ResponseCache(CacheProfileName = "Long-Lived")]
|
||||
public class BaseController : Controller
|
||||
{
|
||||
protected const int MemoryCacheSlidingExpirationSeconds = 30;
|
||||
protected readonly IMemoryCache MemoryCache;
|
||||
|
||||
protected BaseController(IMemoryCache memoryCache)
|
||||
protected BaseController()
|
||||
{
|
||||
MemoryCache = memoryCache;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Models.Seed.Junctions;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class ForksController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public ForksController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public ForksController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public ForksController(IMemoryCache memoryCache, SeedService seedService) : base
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<Fork, ForkSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<Fork, ForkSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Models.Seed;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class LanguagesController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public LanguagesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public LanguagesController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public LanguagesController(IMemoryCache memoryCache, SeedService seedService) :
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<Language, LanguageSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<Language, LanguageSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Models.Seed;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class LicensesController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public LicensesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public LicensesController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public LicensesController(IMemoryCache memoryCache, SeedService seedService) : b
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<License, LicenseSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<License, LicenseSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Models.Seed;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -13,8 +11,7 @@ public class ListsController : BaseController
|
|||
private readonly FilterListService filterListService;
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public ListsController(IMemoryCache memoryCache, SeedService seedService, FilterListService filterListService) :
|
||||
base(memoryCache)
|
||||
public ListsController(SeedService seedService, FilterListService filterListService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
this.filterListService = filterListService;
|
||||
|
|
@ -23,21 +20,13 @@ public ListsController(IMemoryCache memoryCache, SeedService seedService, Filter
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await filterListService.GetAllSummaries());
|
||||
});
|
||||
return Json(await filterListService.GetAllSummaries());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<FilterList, FilterListSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<FilterList, FilterListSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Models.Seed.Junctions;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class ListsLanguagesController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public ListsLanguagesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public ListsLanguagesController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public ListsLanguagesController(IMemoryCache memoryCache, SeedService seedServic
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<FilterListLanguage, FilterListLanguageSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<FilterListLanguage, FilterListLanguageSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Models.Seed.Junctions;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class ListsMaintainersController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public ListsMaintainersController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public ListsMaintainersController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public ListsMaintainersController(IMemoryCache memoryCache, SeedService seedServ
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<FilterListMaintainer, FilterListMaintainerSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<FilterListMaintainer, FilterListMaintainerSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Models.Seed;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class MaintainersController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public MaintainersController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public MaintainersController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public MaintainersController(IMemoryCache memoryCache, SeedService seedService)
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<Maintainer, MaintainerSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<Maintainer, MaintainerSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Models.Seed.Junctions;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class MergesController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public MergesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public MergesController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public MergesController(IMemoryCache memoryCache, SeedService seedService) : bas
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<Merge, MergeSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<Merge, MergeSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Models.Seed;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class SoftwareController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public SoftwareController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public SoftwareController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public SoftwareController(IMemoryCache memoryCache, SeedService seedService) : b
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<Software, SoftwareSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<Software, SoftwareSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Models.Seed.Junctions;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class SoftwareSyntaxesController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public SoftwareSyntaxesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public SoftwareSyntaxesController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public SoftwareSyntaxesController(IMemoryCache memoryCache, SeedService seedServ
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<SoftwareSyntax, SoftwareSyntaxSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<SoftwareSyntax, SoftwareSyntaxSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Models.Seed;
|
||||
using FilterLists.Services.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ public class SyntaxesController : BaseController
|
|||
{
|
||||
private readonly SeedService seedService;
|
||||
|
||||
public SyntaxesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache)
|
||||
public SyntaxesController(SeedService seedService)
|
||||
{
|
||||
this.seedService = seedService;
|
||||
}
|
||||
|
|
@ -20,11 +18,7 @@ public SyntaxesController(IMemoryCache memoryCache, SeedService seedService) : b
|
|||
[HttpGet]
|
||||
public async Task<IActionResult> Seed()
|
||||
{
|
||||
return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds);
|
||||
return Json(await seedService.GetAll<Syntax, SyntaxSeedDto>());
|
||||
});
|
||||
return Json(await seedService.GetAll<Syntax, SyntaxSeedDto>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue