Skip to content

Commit

Permalink
This ensures we only cache if we want to, I am hoping this will reduc…
Browse files Browse the repository at this point in the history
…e the amount of RAM used for larger projects.
  • Loading branch information
poppastring committed Sep 6, 2019
1 parent ac4e009 commit f55bbe6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/DasBlog.Web.UI/Controllers/HomeController.cs
Expand Up @@ -24,11 +24,11 @@ public class HomeController : DasBlogBaseController
private readonly ILogger<HomeController> logger;
private readonly IMemoryCache memoryCache;

public HomeController(IBlogManager blogManager, IDasBlogSettings settings, IXmlRpcManager rpcManager,
IMapper mapper, ILogger<HomeController> logger, IMemoryCache memoryCache) : base(settings)
public HomeController(IBlogManager blogManager, IDasBlogSettings dasblogsettings, IXmlRpcManager rpcManager,
IMapper mapper, ILogger<HomeController> logger, IMemoryCache memoryCache) : base(dasblogsettings)
{
this.blogManager = blogManager;
dasBlogSettings = settings;
this.dasBlogSettings = dasblogsettings;
this.mapper = mapper;
this.logger = logger;
this.memoryCache = memoryCache;
Expand All @@ -47,7 +47,10 @@ public IActionResult Index()

AddComments(lpvm);

memoryCache.Set(CACHEKEY_FRONTPAGE, lpvm, SiteCacheSettings());
if (dasBlogSettings.SiteConfiguration.EnableStartPageCaching)
{
memoryCache.Set(CACHEKEY_FRONTPAGE, lpvm, SiteCacheSettings());
}

logger.LogDebug($"In Index - {lpvm.Posts.Count} post found");
}
Expand Down

0 comments on commit f55bbe6

Please sign in to comment.