From b2cc1a07f73dca278f07b6832764321d80771344 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Thu, 25 Jan 2018 14:36:47 -0600 Subject: [PATCH] strip out all caching for now (was leaking across endpoints) --- src/FilterLists.Api/CacheKeys.cs | 9 --------- .../Extensions/ConfigureServicesCollection.cs | 17 +---------------- src/FilterLists.Api/Startup.cs | 1 - .../V1/Controllers/BaseController.cs | 9 +-------- .../V1/Controllers/ForksController.cs | 12 +++--------- .../V1/Controllers/LanguagesController.cs | 12 +++--------- .../V1/Controllers/LicensesController.cs | 12 +++--------- .../V1/Controllers/ListsController.cs | 19 ++++--------------- .../Controllers/ListsLanguagesController.cs | 12 +++--------- .../Controllers/ListsMaintainersController.cs | 12 +++--------- .../V1/Controllers/MaintainersController.cs | 12 +++--------- .../V1/Controllers/MergesController.cs | 12 +++--------- .../V1/Controllers/SoftwareController.cs | 12 +++--------- .../Controllers/SoftwareSyntaxesController.cs | 12 +++--------- .../V1/Controllers/SyntaxesController.cs | 12 +++--------- 15 files changed, 36 insertions(+), 139 deletions(-) delete mode 100644 src/FilterLists.Api/CacheKeys.cs diff --git a/src/FilterLists.Api/CacheKeys.cs b/src/FilterLists.Api/CacheKeys.cs deleted file mode 100644 index 4e0666dc4..000000000 --- a/src/FilterLists.Api/CacheKeys.cs +++ /dev/null @@ -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"; - } -} \ No newline at end of file diff --git a/src/FilterLists.Api/DependencyInjection/Extensions/ConfigureServicesCollection.cs b/src/FilterLists.Api/DependencyInjection/Extensions/ConfigureServicesCollection.cs index cd92407a3..8a8f3a7a4 100644 --- a/src/FilterLists.Api/DependencyInjection/Extensions/ConfigureServicesCollection.cs +++ b/src/FilterLists.Api/DependencyInjection/Extensions/ConfigureServicesCollection.cs @@ -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 => diff --git a/src/FilterLists.Api/Startup.cs b/src/FilterLists.Api/Startup.cs index d92904a1e..535cf1344 100644 --- a/src/FilterLists.Api/Startup.cs +++ b/src/FilterLists.Api/Startup.cs @@ -31,7 +31,6 @@ public void Configure(IApplicationBuilder app) { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); - app.UseResponseCaching(); app.UseSwagger(); app.UseSwaggerUI(c => { diff --git a/src/FilterLists.Api/V1/Controllers/BaseController.cs b/src/FilterLists.Api/V1/Controllers/BaseController.cs index c39de2813..f46f0e31d 100644 --- a/src/FilterLists.Api/V1/Controllers/BaseController.cs +++ b/src/FilterLists.Api/V1/Controllers/BaseController.cs @@ -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; } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/ForksController.cs b/src/FilterLists.Api/V1/Controllers/ForksController.cs index b05795799..658c22ab0 100644 --- a/src/FilterLists.Api/V1/Controllers/ForksController.cs +++ b/src/FilterLists.Api/V1/Controllers/ForksController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/LanguagesController.cs b/src/FilterLists.Api/V1/Controllers/LanguagesController.cs index fc418c04c..c9bb163d5 100644 --- a/src/FilterLists.Api/V1/Controllers/LanguagesController.cs +++ b/src/FilterLists.Api/V1/Controllers/LanguagesController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/LicensesController.cs b/src/FilterLists.Api/V1/Controllers/LicensesController.cs index 994423a19..7ce150e74 100644 --- a/src/FilterLists.Api/V1/Controllers/LicensesController.cs +++ b/src/FilterLists.Api/V1/Controllers/LicensesController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/ListsController.cs b/src/FilterLists.Api/V1/Controllers/ListsController.cs index 7b3592adf..066490f89 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsController.cs @@ -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 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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs b/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs index 1d1e02a5d..bc4e43773 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsLanguagesController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs b/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs index 4d3d8f911..06f6d945b 100644 --- a/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs +++ b/src/FilterLists.Api/V1/Controllers/ListsMaintainersController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/MaintainersController.cs b/src/FilterLists.Api/V1/Controllers/MaintainersController.cs index 861d2b68b..bf2fd4df0 100644 --- a/src/FilterLists.Api/V1/Controllers/MaintainersController.cs +++ b/src/FilterLists.Api/V1/Controllers/MaintainersController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/MergesController.cs b/src/FilterLists.Api/V1/Controllers/MergesController.cs index 7ccc28a88..1a845c53a 100644 --- a/src/FilterLists.Api/V1/Controllers/MergesController.cs +++ b/src/FilterLists.Api/V1/Controllers/MergesController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/SoftwareController.cs b/src/FilterLists.Api/V1/Controllers/SoftwareController.cs index d3f583e47..701d40051 100644 --- a/src/FilterLists.Api/V1/Controllers/SoftwareController.cs +++ b/src/FilterLists.Api/V1/Controllers/SoftwareController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs b/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs index 80f26277a..4e6ea543e 100644 --- a/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs +++ b/src/FilterLists.Api/V1/Controllers/SoftwareSyntaxesController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs b/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs index e60910569..dc3fbd4b3 100644 --- a/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs +++ b/src/FilterLists.Api/V1/Controllers/SyntaxesController.cs @@ -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 Seed() { - return await MemoryCache.GetOrCreateAsync(CacheKeys.Entry, async entry => - { - entry.SlidingExpiration = TimeSpan.FromSeconds(MemoryCacheSlidingExpirationSeconds); - return Json(await seedService.GetAll()); - }); + return Json(await seedService.GetAll()); } } } \ No newline at end of file