diff --git a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
index ad79cfc44a..235c18a7a8 100644
--- a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
@@ -32,6 +32,7 @@ namespace Umbraco.Core.Persistence.Repositories
private readonly ITemplatesSection _templateConfig;
private readonly ViewHelper _viewHelper;
private readonly MasterPageHelper _masterPageHelper;
+ private readonly RepositoryCacheOptions _cacheOptions;
internal TemplateRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax, IFileSystem masterpageFileSystem, IFileSystem viewFileSystem, ITemplatesSection templateConfig)
: base(work, cache, logger, sqlSyntax)
@@ -41,9 +42,27 @@ namespace Umbraco.Core.Persistence.Repositories
_templateConfig = templateConfig;
_viewHelper = new ViewHelper(_viewsFileSystem);
_masterPageHelper = new MasterPageHelper(_masterpagesFileSystem);
+
+ _cacheOptions = new RepositoryCacheOptions
+ {
+ //Allow a zero count cache entry because GetAll() gets used quite a lot and we want to ensure
+ // if there are no templates, that it doesn't keep going to the db.
+ GetAllCacheAllowZeroCount = true,
+ //GetAll gets called a lot, we want to ensure that all templates are in the cache, default is 100 which
+ // would normally be fine but we'll increase it in case people have a ton of templates.
+ GetAllCacheThresholdLimit = 500
+ };
+ }
+
+
+ ///
+ /// Returns the repository cache options
+ ///
+ protected override RepositoryCacheOptions RepositoryCacheOptions
+ {
+ get { return _cacheOptions; }
}
-
#region Overrides of RepositoryBase
protected override ITemplate PerformGet(int id)