From d5c8430cd2bbcc99d19cc7ad3b254e03354c084b Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 13 Jan 2015 13:33:39 +1100 Subject: [PATCH] Removes all IRepositoryCacheProvider's, we are just using a single cache construct to which is much easier to manage. --- .../Caching/IRepositoryCacheProvider.cs | 57 ----- .../Caching/InMemoryCacheProvider.cs | 142 ----------- .../Persistence/Caching/NullCacheProvider.cs | 57 ----- .../Caching/RuntimeCacheProvider.cs | 238 ------------------ .../Repositories/ContentPreviewRepository.cs | 2 +- .../Repositories/ContentRepository.cs | 2 +- .../Repositories/ContentTypeBaseRepository.cs | 2 +- .../Repositories/ContentTypeRepository.cs | 2 +- .../Repositories/ContentXmlRepository.cs | 2 +- .../DataTypeDefinitionRepository.cs | 3 +- .../Repositories/DictionaryRepository.cs | 2 +- .../Repositories/LanguageRepository.cs | 2 +- .../Repositories/MacroRepository.cs | 2 +- .../Repositories/MediaRepository.cs | 2 +- .../Repositories/MediaTypeRepository.cs | 2 +- .../Repositories/MemberGroupRepository.cs | 2 +- .../Repositories/MemberRepository.cs | 2 +- .../Repositories/MemberTypeRepository.cs | 2 +- .../Repositories/PetaPocoRepositoryBase.cs | 2 +- .../Repositories/RecycleBinRepository.cs | 2 +- .../Repositories/RelationRepository.cs | 2 +- .../Repositories/RelationTypeRepository.cs | 2 +- .../Repositories/RepositoryBase.cs | 2 +- .../ServerRegistrationRepository.cs | 2 +- .../Repositories/SimpleGetRepository.cs | 2 +- .../Persistence/Repositories/TagRepository.cs | 2 +- .../Repositories/TemplateRepository.cs | 2 +- .../Repositories/UserRepository.cs | 2 +- .../Repositories/UserTypeRepository.cs | 2 +- .../Repositories/VersionableRepositoryBase.cs | 2 +- .../Persistence/RepositoryFactory.cs | 2 +- src/Umbraco.Core/Services/ContentService.cs | 7 +- src/Umbraco.Core/Umbraco.Core.csproj | 4 - .../Upgrades/ValidateV7TagsUpgradeTest.cs | 2 +- src/Umbraco.Tests/Models/ContentTests.cs | 2 +- .../Caching/InMemoryCacheProviderTest.cs | 118 --------- .../Caching/RuntimeCacheProviderTest.cs | 138 ---------- .../Repositories/ContentRepositoryTest.cs | 2 +- .../Repositories/ContentTypeRepositoryTest.cs | 2 +- .../DataTypeDefinitionRepositoryTest.cs | 2 - .../Repositories/DictionaryRepositoryTest.cs | 2 +- .../Repositories/LanguageRepositoryTest.cs | 2 +- .../Repositories/MacroRepositoryTest.cs | 2 +- .../Repositories/MediaRepositoryTest.cs | 2 +- .../Repositories/MediaTypeRepositoryTest.cs | 2 +- .../Repositories/MemberRepositoryTest.cs | 2 +- .../Repositories/MemberTypeRepositoryTest.cs | 2 +- .../Repositories/RelationRepositoryTest.cs | 2 +- .../RelationTypeRepositoryTest.cs | 2 +- .../ServerRegistrationRepositoryTest.cs | 2 +- .../Repositories/TagRepositoryTest.cs | 2 +- .../Repositories/TemplateRepositoryTest.cs | 2 +- .../Repositories/UserRepositoryTest.cs | 2 +- .../Repositories/UserTypeRepositoryTest.cs | 2 +- .../Services/ContentTypeServiceTests.cs | 2 +- .../Services/MacroServiceTests.cs | 2 +- .../Services/PerformanceTests.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 2 - .../Cache/ContentTypeCacheRefresher.cs | 5 +- .../Cache/DataTypeCacheRefresher.cs | 8 +- .../Cache/DictionaryCacheRefresher.cs | 10 +- .../Cache/LanguageCacheRefresher.cs | 6 +- src/Umbraco.Web/Cache/MacroCacheRefresher.cs | 4 +- src/Umbraco.Web/Cache/MediaCacheRefresher.cs | 3 +- src/Umbraco.Web/Cache/MemberCacheRefresher.cs | 3 +- .../Cache/MemberGroupCacheRefresher.cs | 3 +- .../Cache/TemplateCacheRefresher.cs | 3 +- .../Cache/UnpublishedPageCacheRefresher.cs | 8 +- src/Umbraco.Web/Cache/UserCacheRefresher.cs | 4 +- .../Cache/UserTypeCacheRefresher.cs | 5 +- src/umbraco.businesslogic/User.cs | 3 +- src/umbraco.cms/businesslogic/CMSNode.cs | 7 +- src/umbraco.cms/businesslogic/ContentType.cs | 6 +- .../propertytype/propertytype.cs | 4 +- src/umbraco.cms/businesslogic/web/Document.cs | 3 +- 75 files changed, 68 insertions(+), 879 deletions(-) delete mode 100644 src/Umbraco.Core/Persistence/Caching/IRepositoryCacheProvider.cs delete mode 100644 src/Umbraco.Core/Persistence/Caching/InMemoryCacheProvider.cs delete mode 100644 src/Umbraco.Core/Persistence/Caching/NullCacheProvider.cs delete mode 100644 src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs delete mode 100644 src/Umbraco.Tests/Persistence/Caching/InMemoryCacheProviderTest.cs delete mode 100644 src/Umbraco.Tests/Persistence/Caching/RuntimeCacheProviderTest.cs diff --git a/src/Umbraco.Core/Persistence/Caching/IRepositoryCacheProvider.cs b/src/Umbraco.Core/Persistence/Caching/IRepositoryCacheProvider.cs deleted file mode 100644 index fca941d6eb..0000000000 --- a/src/Umbraco.Core/Persistence/Caching/IRepositoryCacheProvider.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core.Cache; -using Umbraco.Core.Models.EntityBase; - -namespace Umbraco.Core.Persistence.Caching -{ - - /// - /// Defines the implementation of a Cache Provider intented to back a repository - /// - internal interface IRepositoryCacheProvider - { - /// - /// Gets an Entity from the cache by Type and Id - /// - /// - /// - /// - IEntity GetById(Type type, Guid id); - - /// - /// Gets an Entity from the cache by Type and Ids - /// - /// - /// - /// - IEnumerable GetByIds(Type type, List ids); - - /// - /// Gets all Entities of specified type - /// - /// - /// - IEnumerable GetAllByType(Type type); - - /// - /// Saves the Entity - /// - /// - /// - void Save(Type type, IEntity entity); - - /// - /// Deletes the Entity from the cache - /// - /// - /// - void Delete(Type type, IEntity entity); - - /// - /// Clears the cache by type - /// - /// - void Clear(Type type); - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Caching/InMemoryCacheProvider.cs b/src/Umbraco.Core/Persistence/Caching/InMemoryCacheProvider.cs deleted file mode 100644 index 7572dcd5c5..0000000000 --- a/src/Umbraco.Core/Persistence/Caching/InMemoryCacheProvider.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using Umbraco.Core.Models.EntityBase; - -namespace Umbraco.Core.Persistence.Caching -{ - /// - /// The InMemory registry looks up objects in an in-memory dictionary for fast retrival - /// - internal class InMemoryCacheProvider : IRepositoryCacheProvider - { - #region Singleton - - private static readonly Lazy lazy = new Lazy(() => new InMemoryCacheProvider()); - - public static InMemoryCacheProvider Current { get { return lazy.Value; } } - - private InMemoryCacheProvider() - { - } - - #endregion - - private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); - - /// - /// Retrives an object of the specified type by its Id - /// - /// The type of the object to retrive, which implements - /// The Guid Id of the Object to retrive - /// - public IEntity GetById(Type type, Guid id) - { - var compositeKey = GetCompositeId(type, id); - var containsKey = _cache.ContainsKey(compositeKey); - if (containsKey) - { - var result = _cache[compositeKey]; - - //IMPORTANT: we must clone to resolve, see: http://issues.umbraco.org/issue/U4-4259 - return (IEntity)result.DeepClone(); - } - - return null; - } - - /// - /// Retrives objects of the specified type by their Ids - /// - /// The type of the objects to retrive, which implements - /// The Guid Ids of the Objects to retrive - /// - public IEnumerable GetByIds(Type type, List ids) - { - var list = (from id in ids - select GetCompositeId(type, id) - into key - let containsKey = _cache.ContainsKey(key) - where containsKey - select _cache[key] - into result - //don't return null objects - where result != null - //IMPORTANT: we must clone to resolve, see: http://issues.umbraco.org/issue/U4-4259 - select (IEntity)result.DeepClone()).ToList(); - return list; - } - - /// - /// Retrives all objects of the specified type - /// - /// The type of the objects to retrive, which implements - /// - public IEnumerable GetAllByType(Type type) - { - var list = _cache.Keys - .Where(key => key.Contains(type.Name)) - .Select(key => _cache[key]) - //don't return null objects - .Where(result => result != null) - //IMPORTANT: we must clone to resolve, see: http://issues.umbraco.org/issue/U4-4259 - .Select(result => (IEntity)result.DeepClone()) - .ToList(); - return list; - } - - /// - /// Saves an object in the registry cache - /// - /// - /// - public void Save(Type type, IEntity entity) - { - //IMPORTANT: we must clone to store, see: http://issues.umbraco.org/issue/U4-4259 - entity = (IEntity)entity.DeepClone(); - - _cache.AddOrUpdate(GetCompositeId(type, entity.Id), entity, (x, y) => entity); - } - - /// - /// Deletes an object from the registry cache - /// - /// - /// - public void Delete(Type type, IEntity entity) - { - IEntity entity1; - bool result = _cache.TryRemove(GetCompositeId(type, entity.Id), out entity1); - } - - /// - /// Clear cache by type - /// - /// - public void Clear(Type type) - { - var keys = _cache.Keys; - foreach (var key in keys.Where(x => x.StartsWith(string.Format("{0}-", type.Name)))) - { - IEntity e; - _cache.TryRemove(key, out e); - } - } - - public void Clear() - { - _cache.Clear(); - } - - private string GetCompositeId(Type type, Guid id) - { - return string.Format("{0}-{1}", type.Name, id.ToString()); - } - - private string GetCompositeId(Type type, int id) - { - return string.Format("{0}-{1}", type.Name, id.ToGuid()); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Caching/NullCacheProvider.cs b/src/Umbraco.Core/Persistence/Caching/NullCacheProvider.cs deleted file mode 100644 index 7779bc3cac..0000000000 --- a/src/Umbraco.Core/Persistence/Caching/NullCacheProvider.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Umbraco.Core.Models.EntityBase; - -namespace Umbraco.Core.Persistence.Caching -{ - //TODO: Remove this singleton! - internal class NullCacheProvider : IRepositoryCacheProvider - { - #region Singleton - - private static readonly Lazy lazy = new Lazy(() => new NullCacheProvider()); - - public static NullCacheProvider Current { get { return lazy.Value; } } - - private NullCacheProvider() - { - } - - #endregion - - #region Implementation of IRepositoryCacheProvider - - public IEntity GetById(Type type, Guid id) - { - return null; - } - - public IEnumerable GetByIds(Type type, List ids) - { - return Enumerable.Empty(); - } - - public IEnumerable GetAllByType(Type type) - { - return Enumerable.Empty(); - } - - public void Save(Type type, IEntity entity) - { - return; - } - - public void Delete(Type type, IEntity entity) - { - return; - } - - public void Clear(Type type) - { - return; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs b/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs deleted file mode 100644 index ac9c9f5a65..0000000000 --- a/src/Umbraco.Core/Persistence/Caching/RuntimeCacheProvider.cs +++ /dev/null @@ -1,238 +0,0 @@ -//using System; -//using System.Collections; -//using System.Collections.Concurrent; -//using System.Collections.Generic; -//using System.Linq; -//using System.Runtime.Caching; -//using System.Threading; -//using System.Web; -//using Umbraco.Core.Models.EntityBase; - -//namespace Umbraco.Core.Persistence.Caching -//{ -// //TODO: Remove this singleton! - -// /// -// /// The Runtime Cache provider looks up objects in the Runtime cache for fast retrival -// /// -// /// -// /// -// /// If a web session is detected then the HttpRuntime.Cache will be used for the runtime cache, otherwise a custom -// /// MemoryCache instance will be used. It is important to use the HttpRuntime.Cache when a web session is detected so -// /// that the memory management of cache in IIS can be handled appopriately. -// /// -// /// When a web sessions is detected we will pre-fix all HttpRuntime.Cache entries so that when we clear it we are only -// /// clearing items that have been inserted by this provider. -// /// -// /// NOTE: These changes are all temporary until we finalize the ApplicationCache implementation which will support static cache, runtime cache -// /// and request based cache which will all live in one central location so it is easily managed. -// /// -// /// Also note that we don't always keep checking if HttpContext.Current == null and instead check for _memoryCache != null. This is because -// /// when there are async requests being made even in the context of a web request, the HttpContext.Current will be null but the HttpRuntime.Cache will -// /// always be available. -// /// -// /// -// internal sealed class RuntimeCacheProvider : IRepositoryCacheProvider -// { -// #region Singleton - -// private static readonly Lazy lazy = new Lazy(() => new RuntimeCacheProvider()); - -// public static RuntimeCacheProvider Current { get { return lazy.Value; } } - -// //internal for testing! - though I'm not a huge fan of these being singletons! -// internal RuntimeCacheProvider() -// { -// if (HttpContext.Current == null) -// { -// _memoryCache = new MemoryCache("in-memory"); -// } -// } - -// #endregion - -// //TODO Save this in cache as well, so its not limited to a single server usage -// private readonly ConcurrentHashSet _keyTracker = new ConcurrentHashSet(); -// private ObjectCache _memoryCache; -// private static readonly ReaderWriterLockSlim ClearLock = new ReaderWriterLockSlim(); - -// public IEntity GetById(Type type, Guid id) -// { -// var key = GetCompositeId(type, id); -// var item = _memoryCache != null -// ? _memoryCache.Get(key) -// : HttpRuntime.Cache.Get(key); -// var result = item as IEntity; -// if (result == null) -// { -// //ensure the key doesn't exist anymore in the tracker -// _keyTracker.Remove(key); -// return null; -// } - -// //IMPORTANT: we must clone to resolve, see: http://issues.umbraco.org/issue/U4-4259 -// return (IEntity)result.DeepClone(); -// } - -// public IEnumerable GetByIds(Type type, List ids) -// { -// var collection = new List(); -// foreach (var guid in ids) -// { -// var key = GetCompositeId(type, guid); -// var item = _memoryCache != null -// ? _memoryCache.Get(key) -// : HttpRuntime.Cache.Get(key); -// var result = item as IEntity; -// if (result == null) -// { -// //ensure the key doesn't exist anymore in the tracker -// _keyTracker.Remove(key); -// } -// else -// { -// //IMPORTANT: we must clone to resolve, see: http://issues.umbraco.org/issue/U4-4259 -// collection.Add((IEntity)result.DeepClone()); -// } -// } -// return collection; -// } - -// public IEnumerable GetAllByType(Type type) -// { -// var collection = new List(); -// foreach (var key in _keyTracker) -// { -// if (key.StartsWith(string.Format("{0}{1}-", CacheItemPrefix, type.Name))) -// { -// var item = _memoryCache != null -// ? _memoryCache.Get(key) -// : HttpRuntime.Cache.Get(key); - -// var result = item as IEntity; -// if (result == null) -// { -// //ensure the key doesn't exist anymore in the tracker -// _keyTracker.Remove(key); -// } -// else -// { -// //IMPORTANT: we must clone to resolve, see: http://issues.umbraco.org/issue/U4-4259 -// collection.Add((IEntity)result.DeepClone()); -// } -// } -// } -// return collection; -// } - -// public void Save(Type type, IEntity entity) -// { -// //IMPORTANT: we must clone to store, see: http://issues.umbraco.org/issue/U4-4259 -// var clone = (IEntity)entity.DeepClone(); - -// var key = GetCompositeId(type, clone.Key); - -// _keyTracker.TryAdd(key); - -// //NOTE: Before we were checking if it already exists but the MemoryCache.Set handles this implicitly and does -// // an add or update, same goes for HttpRuntime.Cache.Insert. - -// if (_memoryCache != null) -// { -// _memoryCache.Set(key, clone, new CacheItemPolicy { SlidingExpiration = TimeSpan.FromMinutes(5) }); -// } -// else -// { -// HttpRuntime.Cache.Insert(key, clone, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5)); -// } -// } - -// public void Delete(Type type, IEntity entity) -// { -// var key = GetCompositeId(type, entity.Key); -// if (_memoryCache != null) -// { -// _memoryCache.Remove(key); -// } -// else -// { -// HttpRuntime.Cache.Remove(key); -// } - -// _keyTracker.Remove(key); -// } - -// /// -// /// Clear cache by type -// /// -// /// -// public void Clear(Type type) -// { -// using (new WriteLock(ClearLock)) -// { -// var keys = new string[_keyTracker.Count]; -// _keyTracker.CopyTo(keys, 0); -// var keysToRemove = new List(); -// foreach (var key in keys.Where(x => x.StartsWith(string.Format("{0}{1}-", CacheItemPrefix, type.Name)))) -// { -// _keyTracker.Remove(key); -// keysToRemove.Add(key); -// } -// foreach (var key in keysToRemove) -// { -// if (_memoryCache != null) -// { -// _memoryCache.Remove(key); -// } -// else -// { -// HttpRuntime.Cache.Remove(key); -// } -// } -// } -// } - -// public void Clear() -// { -// using (new WriteLock(ClearLock)) -// { -// _keyTracker.Clear(); - -// ClearDataCache(); -// } -// } - -// //DO not call this unless it's for testing since it clears the data cached but not the keys -// internal void ClearDataCache() -// { -// if (_memoryCache != null) -// { -// _memoryCache.DisposeIfDisposable(); -// _memoryCache = new MemoryCache("in-memory"); -// } -// else -// { -// foreach (DictionaryEntry c in HttpRuntime.Cache) -// { -// if (c.Key is string && ((string)c.Key).InvariantStartsWith(CacheItemPrefix)) -// { -// if (HttpRuntime.Cache[(string)c.Key] == null) return; -// HttpRuntime.Cache.Remove((string)c.Key); -// } -// } -// } -// } - -// /// -// /// We prefix all cache keys with this so that we know which ones this class has created when -// /// using the HttpRuntime cache so that when we clear it we don't clear other entries we didn't create. -// /// -// private const string CacheItemPrefix = "umbrtmche_"; - -// private string GetCompositeId(Type type, Guid id) -// { -// return string.Format("{0}{1}-{2}", CacheItemPrefix, type.Name, id); -// } - -// } -//} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentPreviewRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentPreviewRepository.cs index d961cfed6b..ed1b4b9ca3 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentPreviewRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentPreviewRepository.cs @@ -4,7 +4,7 @@ using System.Xml.Linq; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index c335fd25a6..a1a476e49a 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -15,7 +15,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index 6867194db6..937ce1c50d 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -10,7 +10,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Relators; diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs index 07e57b9e28..6de0eb160d 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Relators; diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentXmlRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentXmlRepository.cs index 75700ff4ce..c0fc368128 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentXmlRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentXmlRepository.cs @@ -4,7 +4,7 @@ using System.Xml.Linq; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs index 84fc065598..1e4cb8b4d4 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs @@ -9,13 +9,12 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.Services; -using NullCacheProvider = Umbraco.Core.Persistence.Caching.NullCacheProvider; namespace Umbraco.Core.Persistence.Repositories { diff --git a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs index 03f7518dfc..8d165fd862 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Relators; diff --git a/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs index 5da738d4e7..bd3737c96a 100644 --- a/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs index 7d02a31d4c..5909df69db 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Relators; diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs index dad616f837..307bf90eac 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs index 18f7285e8b..a676886c21 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/MemberGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MemberGroupRepository.cs index 3719dd0ee1..968d058e18 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MemberGroupRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MemberGroupRepository.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.SqlSyntax; diff --git a/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs index c5f05d4d96..dd3ff093f3 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; diff --git a/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs index 864fe936cd..2c041f2c89 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Relators; diff --git a/src/Umbraco.Core/Persistence/Repositories/PetaPocoRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/PetaPocoRepositoryBase.cs index 9ed04d9020..81185f39e7 100644 --- a/src/Umbraco.Core/Persistence/Repositories/PetaPocoRepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/PetaPocoRepositoryBase.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs b/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs index 420b194453..7c09aeccb6 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs @@ -7,7 +7,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/RelationRepository.cs b/src/Umbraco.Core/Persistence/Repositories/RelationRepository.cs index 7ee663ee77..2991caf4c4 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RelationRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RelationRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/RelationTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/RelationTypeRepository.cs index 65a07d767f..b842959748 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RelationTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RelationTypeRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs index edb8b27e86..ca33e16cf1 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs @@ -4,7 +4,7 @@ using System.Linq; using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/ServerRegistrationRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ServerRegistrationRepository.cs index 6eafb5ef5e..eddf0cf7b7 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ServerRegistrationRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ServerRegistrationRepository.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/SimpleGetRepository.cs b/src/Umbraco.Core/Persistence/Repositories/SimpleGetRepository.cs index af0db54955..c3da845478 100644 --- a/src/Umbraco.Core/Persistence/Repositories/SimpleGetRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/SimpleGetRepository.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/TagRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TagRepository.cs index 53b2971fea..587c41731d 100644 --- a/src/Umbraco.Core/Persistence/Repositories/TagRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/TagRepository.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.SqlSyntax; diff --git a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs index df7b0dc1e7..784276a22e 100644 --- a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.SqlSyntax; diff --git a/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs index 6d4bb7f2ba..d935f32a1f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs @@ -8,7 +8,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence.Querying; diff --git a/src/Umbraco.Core/Persistence/Repositories/UserTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/UserTypeRepository.cs index 1b9c2469b1..f39d220748 100644 --- a/src/Umbraco.Core/Persistence/Repositories/UserTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/UserTypeRepository.cs @@ -4,7 +4,7 @@ using System.Linq; using Umbraco.Core.Logging; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs index c4b21dbd9d..d9671b8e98 100644 --- a/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs @@ -8,7 +8,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Factories; using Umbraco.Core.Persistence.Querying; diff --git a/src/Umbraco.Core/Persistence/RepositoryFactory.cs b/src/Umbraco.Core/Persistence/RepositoryFactory.cs index bf1e1395ad..e82c07fba5 100644 --- a/src/Umbraco.Core/Persistence/RepositoryFactory.cs +++ b/src/Umbraco.Core/Persistence/RepositoryFactory.cs @@ -3,7 +3,7 @@ using System; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; using Umbraco.Core.Logging; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index eb22e44094..fdc5885cda 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -12,7 +12,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; @@ -1329,11 +1329,6 @@ namespace Umbraco.Core.Services Copied.RaiseEvent(new CopyEventArgs(content, copy, false, parentId, relateToOriginal), this); Audit.Add(AuditTypes.Copy, "Copy Content performed by user", content.WriterId, content.Id); - - ////TODO: Don't think we need this here because cache should be cleared by the event listeners - //// and the correct ICacheRefreshers!? - //RuntimeCacheProvider.Current.Clear(); - return copy; } } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 8231605428..dcade72684 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -539,10 +539,6 @@ - - - - diff --git a/src/Umbraco.Tests/Migrations/Upgrades/ValidateV7TagsUpgradeTest.cs b/src/Umbraco.Tests/Migrations/Upgrades/ValidateV7TagsUpgradeTest.cs index 47a5b9d851..26276181c4 100644 --- a/src/Umbraco.Tests/Migrations/Upgrades/ValidateV7TagsUpgradeTest.cs +++ b/src/Umbraco.Tests/Migrations/Upgrades/ValidateV7TagsUpgradeTest.cs @@ -9,7 +9,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Migrations; using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven; using Umbraco.Core.Persistence.Repositories; diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs index fb1b1520f0..d8dea6b04d 100644 --- a/src/Umbraco.Tests/Models/ContentTests.cs +++ b/src/Umbraco.Tests/Models/ContentTests.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Cache; using Umbraco.Core.Exceptions; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Serialization; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; diff --git a/src/Umbraco.Tests/Persistence/Caching/InMemoryCacheProviderTest.cs b/src/Umbraco.Tests/Persistence/Caching/InMemoryCacheProviderTest.cs deleted file mode 100644 index 775e6ee078..0000000000 --- a/src/Umbraco.Tests/Persistence/Caching/InMemoryCacheProviderTest.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; -using Umbraco.Core; -using Umbraco.Core.Persistence.Caching; -using Umbraco.Tests.TestHelpers.Entities; - -namespace Umbraco.Tests.Persistence.Caching -{ - [TestFixture] - public class InMemoryCacheProviderTest - { - private IRepositoryCacheProvider _registry; - - [SetUp] - public void Initiate_Registry() - { - _registry = InMemoryCacheProvider.Current; - - //Fill the registry with random entities - var entity1 = new MockedEntity { Id = 1, Key = 1.ToGuid(), Alias = "mocked1", Name = "Mocked1", Value = Guid.NewGuid().ToString("n") }; - var entity2 = new MockedEntity { Id = 2, Key = 2.ToGuid(), Alias = "mocked2", Name = "Mocked2", Value = Guid.NewGuid().ToString("n") }; - var entity3 = new MockedEntity { Id = 3, Key = 3.ToGuid(), Alias = "mocked3", Name = "Mocked3", Value = Guid.NewGuid().ToString("n") }; - var entity4 = new MockedEntity { Id = 4, Key = 4.ToGuid(), Alias = "mocked4", Name = "Mocked4", Value = Guid.NewGuid().ToString("n") }; - var entity5 = new MockedEntity { Id = 5, Key = 5.ToGuid(), Alias = "mocked5", Name = "Mocked5", Value = Guid.NewGuid().ToString("n") }; - var entity6 = new MockedEntity { Id = 6, Key = 6.ToGuid(), Alias = "mocked6", Name = "Mocked6", Value = Guid.NewGuid().ToString("n") }; - - _registry.Save(typeof(MockedEntity), entity1); - _registry.Save(typeof(MockedEntity), entity2); - _registry.Save(typeof(MockedEntity), entity3); - _registry.Save(typeof(MockedEntity), entity4); - _registry.Save(typeof(MockedEntity), entity5); - _registry.Save(typeof(MockedEntity), entity6); - } - - [Test] - public void Can_Clear_By_Type() - { - var customObj1 = new CustomMockedEntity { Id = 5, Key = 5.ToGuid(), Alias = "mocked5", Name = "Mocked5", Value = Guid.NewGuid().ToString("n") }; - var customObj2 = new CustomMockedEntity { Id = 6, Key = 6.ToGuid(), Alias = "mocked6", Name = "Mocked6", Value = Guid.NewGuid().ToString("n") }; - - _registry.Save(typeof(CustomMockedEntity), customObj1); - _registry.Save(typeof(CustomMockedEntity), customObj2); - - Assert.AreEqual(2, _registry.GetAllByType(typeof(CustomMockedEntity)).Count()); - - _registry.Clear(typeof(CustomMockedEntity)); - - Assert.AreEqual(0, _registry.GetAllByType(typeof(CustomMockedEntity)).Count()); - } - - [Test] - public void Can_Get_Entity_From_Registry() - { - // Arrange - var mockedEntity = new MockedEntity { Id = 20, Key = 20.ToGuid(), Alias = "getMocked", Name = "GetMocked", Value = "Getting entity by id test" }; - _registry.Save(typeof(MockedEntity), mockedEntity); - - // Act - var entity = _registry.GetById(mockedEntity.GetType(), mockedEntity.Key); - - // Assert - Assert.That(entity, Is.Not.Null); - Assert.That(entity.Id, Is.EqualTo(mockedEntity.Id)); - Assert.That(entity.GetType(), Is.EqualTo(mockedEntity.GetType())); - } - - [Test] - public void Can_Get_Entities_By_Ids_From_Registry() - { - // Arrange - var mockedEntity1 = new MockedEntity { Id = 30, Key = 30.ToGuid(), Alias = "getMocked1", Name = "GetMocked1", Value = "Entity 1 - Getting entity by ids test" }; - var mockedEntity2 = new MockedEntity { Id = 31, Key = 31.ToGuid(), Alias = "getMocked2", Name = "GetMocked2", Value = "Entity 2 - Getting entity by ids test" }; - _registry.Save(typeof(MockedEntity), mockedEntity1); - _registry.Save(typeof(MockedEntity), mockedEntity2); - - // Act - var entities = _registry.GetByIds(typeof(MockedEntity), new List { mockedEntity1.Key, mockedEntity2.Key }).ToList(); - - // Assert - Assert.That(entities, Is.Not.Null); - Assert.That(entities.Count(), Is.EqualTo(2)); - Assert.That(entities.Any(x => x.Id == mockedEntity1.Id), Is.True); - Assert.That(entities.Any(x => x.Id == mockedEntity2.Id), Is.True); - } - - [Test] - public void Can_Get_Entities_By_Type_From_Registry() - { - var entities = _registry.GetAllByType(typeof(MockedEntity)); - - Assert.That(entities, Is.Not.Null); - Assert.That(entities.Any(), Is.True); - Assert.That(entities.Count(), Is.GreaterThanOrEqualTo(6)); - } - - [Test] - public void Can_Delete_Entity_From_Registry() - { - // Arrange - var mockedEntity = new MockedEntity { Id = 40, Key = 40.ToGuid(), Alias = "deleteMocked", Name = "DeleteMocked", Value = "Deleting entity test" }; - _registry.Save(typeof(MockedEntity), mockedEntity); - var entitiesBeforeDeletion = _registry.GetAllByType(typeof(MockedEntity)); - int countBefore = entitiesBeforeDeletion.Count(); - - // Act - var entity = _registry.GetById(mockedEntity.GetType(), mockedEntity.Key); - _registry.Delete(typeof(MockedEntity), entity); - var entitiesAfterDeletion = _registry.GetAllByType(typeof(MockedEntity)); - int countAfter = entitiesAfterDeletion.Count(); - - // Assert - Assert.That(countBefore, Is.GreaterThan(countAfter)); - Assert.That(entitiesAfterDeletion.Count(x => x.Id == mockedEntity.Id), Is.EqualTo(0)); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Tests/Persistence/Caching/RuntimeCacheProviderTest.cs b/src/Umbraco.Tests/Persistence/Caching/RuntimeCacheProviderTest.cs deleted file mode 100644 index 4cba52a63c..0000000000 --- a/src/Umbraco.Tests/Persistence/Caching/RuntimeCacheProviderTest.cs +++ /dev/null @@ -1,138 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using NUnit.Framework; -//using Umbraco.Core; -//using Umbraco.Core.Persistence.Caching; -//using Umbraco.Tests.TestHelpers.Entities; - -//namespace Umbraco.Tests.Persistence.Caching -//{ -// [TestFixture] -// public class RuntimeCacheProviderTest -// { -// private IRepositoryCacheProvider _registry; - -// [SetUp] -// public void Initiate_Registry() -// { -// _registry = RuntimeCacheProvider.Current; - -// //Fill the registry with random entities -// var entity1 = new MockedEntity { Id = 1, Key = 1.ToGuid(), Alias = "mocked1", Name = "Mocked1", Value = Guid.NewGuid().ToString("n") }; -// var entity2 = new MockedEntity { Id = 2, Key = 2.ToGuid(), Alias = "mocked2", Name = "Mocked2", Value = Guid.NewGuid().ToString("n") }; -// var entity3 = new MockedEntity { Id = 3, Key = 3.ToGuid(), Alias = "mocked3", Name = "Mocked3", Value = Guid.NewGuid().ToString("n") }; -// var entity4 = new MockedEntity { Id = 4, Key = 4.ToGuid(), Alias = "mocked4", Name = "Mocked4", Value = Guid.NewGuid().ToString("n") }; -// var entity5 = new MockedEntity { Id = 5, Key = 5.ToGuid(), Alias = "mocked5", Name = "Mocked5", Value = Guid.NewGuid().ToString("n") }; -// var entity6 = new MockedEntity { Id = 6, Key = 6.ToGuid(), Alias = "mocked6", Name = "Mocked6", Value = Guid.NewGuid().ToString("n") }; - -// _registry.Save(typeof(MockedEntity), entity1); -// _registry.Save(typeof(MockedEntity), entity2); -// _registry.Save(typeof(MockedEntity), entity3); -// _registry.Save(typeof(MockedEntity), entity4); -// _registry.Save(typeof(MockedEntity), entity5); -// _registry.Save(typeof(MockedEntity), entity6); -// } - -// [Test] -// public void Tracked_Keys_Removed_When_Cache_Removed() -// { -// _registry = RuntimeCacheProvider.Current; - -// //Fill the registry with random entities -// var entity1 = new MockedEntity { Id = 1, Key = 1.ToGuid(), Alias = "mocked1", Name = "Mocked1", Value = Guid.NewGuid().ToString("n") }; -// var entity2 = new MockedEntity { Id = 2, Key = 2.ToGuid(), Alias = "mocked2", Name = "Mocked2", Value = Guid.NewGuid().ToString("n") }; -// var entity3 = new MockedEntity { Id = 3, Key = 3.ToGuid(), Alias = "mocked3", Name = "Mocked3", Value = Guid.NewGuid().ToString("n") }; - -// _registry.Save(typeof(MockedEntity), entity1); -// _registry.Save(typeof(MockedEntity), entity2); -// _registry.Save(typeof(MockedEntity), entity3); - -// //now clear the runtime cache internally -// ((RuntimeCacheProvider)_registry).ClearDataCache(); - -// Assert.AreEqual(0, _registry.GetAllByType(typeof (MockedEntity)).Count()); -// } - -// [Test] -// public void Can_Clear_By_Type() -// { -// var customObj1 = new CustomMockedEntity { Id = 5, Key = 5.ToGuid(), Alias = "mocked5", Name = "Mocked5", Value = Guid.NewGuid().ToString("n") }; -// var customObj2 = new CustomMockedEntity { Id = 6, Key = 6.ToGuid(), Alias = "mocked6", Name = "Mocked6", Value = Guid.NewGuid().ToString("n") }; - -// _registry.Save(typeof(CustomMockedEntity), customObj1); -// _registry.Save(typeof(CustomMockedEntity), customObj2); - -// Assert.AreEqual(2, _registry.GetAllByType(typeof(CustomMockedEntity)).Count()); - -// _registry.Clear(typeof(CustomMockedEntity)); - -// Assert.AreEqual(0, _registry.GetAllByType(typeof(CustomMockedEntity)).Count()); -// } - -// [Test] -// public void Can_Get_Entity_From_Registry() -// { -// // Arrange -// var mockedEntity = new MockedEntity { Id = 20, Key = 20.ToGuid(), Alias = "getMocked", Name = "GetMocked", Value = "Getting entity by id test" }; -// _registry.Save(typeof(MockedEntity), mockedEntity); - -// // Act -// var entity = _registry.GetById(mockedEntity.GetType(), mockedEntity.Key); - -// // Assert -// Assert.That(entity, Is.Not.Null); -// Assert.That(entity.Id, Is.EqualTo(mockedEntity.Id)); -// Assert.That(entity.GetType(), Is.EqualTo(mockedEntity.GetType())); -// } - -// [Test] -// public void Can_Get_Entities_By_Ids_From_Registry() -// { -// // Arrange -// var mockedEntity1 = new MockedEntity { Id = 30, Key = 30.ToGuid(), Alias = "getMocked1", Name = "GetMocked1", Value = "Entity 1 - Getting entity by ids test" }; -// var mockedEntity2 = new MockedEntity { Id = 31, Key = 31.ToGuid(), Alias = "getMocked2", Name = "GetMocked2", Value = "Entity 2 - Getting entity by ids test" }; -// _registry.Save(typeof(MockedEntity), mockedEntity1); -// _registry.Save(typeof(MockedEntity), mockedEntity2); - -// // Act -// var entities = _registry.GetByIds(typeof(MockedEntity), new List { mockedEntity1.Key, mockedEntity2.Key }).ToList(); - -// // Assert -// Assert.That(entities, Is.Not.Null); -// Assert.That(entities.Count(), Is.EqualTo(2)); -// Assert.That(entities.Any(x => x.Id == mockedEntity1.Id), Is.True); -// Assert.That(entities.Any(x => x.Id == mockedEntity2.Id), Is.True); -// } - -// [Test] -// public void Can_Get_Entities_By_Type_From_Registry() -// { -// var entities = _registry.GetAllByType(typeof(MockedEntity)); - -// Assert.That(entities, Is.Not.Null); -// Assert.That(entities.Any(), Is.True); -// Assert.That(entities.Count(), Is.GreaterThanOrEqualTo(6)); -// } - -// [Test] -// public void Can_Delete_Entity_From_Registry() -// { -// // Arrange -// var mockedEntity = new MockedEntity { Id = 40, Key = 40.ToGuid(), Alias = "deleteMocked", Name = "DeleteMocked", Value = "Deleting entity test" }; -// _registry.Save(typeof(MockedEntity), mockedEntity); -// var entitiesBeforeDeletion = _registry.GetAllByType(typeof(MockedEntity)); -// int countBefore = entitiesBeforeDeletion.Count(); - -// // Act -// var entity = _registry.GetById(mockedEntity.GetType(), mockedEntity.Key); -// _registry.Delete(typeof(MockedEntity), entity); -// var entitiesAfterDeletion = _registry.GetAllByType(typeof(MockedEntity)); -// int countAfter = entitiesAfterDeletion.Count(); - -// // Assert -// Assert.That(countBefore, Is.GreaterThan(countAfter)); -// Assert.That(entitiesAfterDeletion.Count(x => x.Id == mockedEntity.Id), Is.EqualTo(0)); -// } -// } -//} \ No newline at end of file diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs index d007f989ea..1382687c29 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs index 2cbfed1fd6..e5e9a0847b 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs index 6e0e53e2cf..81ea585c32 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs @@ -12,12 +12,10 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Tests.TestHelpers; -using NullCacheProvider = Umbraco.Core.Persistence.Caching.NullCacheProvider; namespace Umbraco.Tests.Persistence.Repositories { diff --git a/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs index 7516a1b25c..f6ca73c38b 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DictionaryRepositoryTest.cs @@ -6,7 +6,7 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.SqlSyntax; diff --git a/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs index 4d0a235a3d..b25b7ab4e4 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/LanguageRepositoryTest.cs @@ -6,7 +6,7 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs index bcefa91867..78ff3fa740 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MacroRepositoryTest.cs @@ -6,7 +6,7 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs index d691212475..0e2a259832 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs @@ -9,7 +9,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.SqlSyntax; diff --git a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs index 24802a2ca0..8f4d5b09be 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MediaTypeRepositoryTest.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs index 6052e068c0..a300b146a1 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs @@ -8,7 +8,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs index 287bcebf57..5b6eab9889 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/MemberTypeRepositoryTest.cs @@ -6,7 +6,7 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs index 58066d80fc..516db84d8c 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/RelationRepositoryTest.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs index 91cf2c1b61..60c69d1400 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/RelationTypeRepositoryTest.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs index 4acef9bc74..fb70276625 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs @@ -6,7 +6,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs index 597774a226..d3e7605586 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs @@ -9,7 +9,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs index b577378d9f..9d753eebed 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs @@ -10,7 +10,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.Services; diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs index e552168b5d..378b0ae32d 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs @@ -7,7 +7,7 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models.Membership; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs index fe9275d167..d84b942ffc 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserTypeRepositoryTest.cs @@ -5,7 +5,7 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models.Membership; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs index f430a93e23..1bb3abde7c 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs @@ -6,7 +6,7 @@ using System.Linq; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Tests.CodeFirst.TestModels.Composition; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; diff --git a/src/Umbraco.Tests/Services/MacroServiceTests.cs b/src/Umbraco.Tests/Services/MacroServiceTests.cs index 9af3f9f5e0..e9f1f71d15 100644 --- a/src/Umbraco.Tests/Services/MacroServiceTests.cs +++ b/src/Umbraco.Tests/Services/MacroServiceTests.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Services/PerformanceTests.cs b/src/Umbraco.Tests/Services/PerformanceTests.cs index f38fbac92b..438705eec8 100644 --- a/src/Umbraco.Tests/Services/PerformanceTests.cs +++ b/src/Umbraco.Tests/Services/PerformanceTests.cs @@ -11,7 +11,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Persistence.UnitOfWork; diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index b546168407..4f77cdaa0b 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -396,8 +396,6 @@ - - diff --git a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs index 6edeb98911..d07aa61f58 100644 --- a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs @@ -9,7 +9,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache.XmlPublishedCache; @@ -126,8 +126,6 @@ namespace Umbraco.Web.Cache public override void RefreshAll() { - //RuntimeCacheProvider.Current.Clear(typeof(IContent)); - //RuntimeCacheProvider.Current.Clear(typeof(IContentType)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); @@ -179,7 +177,6 @@ namespace Umbraco.Web.Cache /// -- CacheKeys.ContentTypePropertiesCacheKey + contentType.Id /// - ContentType.RemoveFromDataTypeCache (clears static object/dictionary cache) /// - InMemoryCacheProvider.Current.Clear(); - /// - RuntimeCacheProvider.Current.Clear(); /// - RoutesCache.Clear(); /// private static void ClearContentTypeCache(JsonPayload[] payloads) diff --git a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs index fb43268834..03a1bcef08 100644 --- a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Cache; using System.Linq; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.Persistence.Caching; + namespace Umbraco.Web.Cache { @@ -120,12 +120,6 @@ namespace Umbraco.Web.Cache // db data type to store the value against and anytime a datatype changes, this also might change // we basically need to clear all sorts of runtime caches here because so many things depend upon a data type - //RuntimeCacheProvider.Current.Clear(typeof(IContent)); - //RuntimeCacheProvider.Current.Clear(typeof (IContentType)); - //RuntimeCacheProvider.Current.Clear(typeof(IMedia)); - //RuntimeCacheProvider.Current.Clear(typeof(IMediaType)); - //RuntimeCacheProvider.Current.Clear(typeof(IMember)); - //RuntimeCacheProvider.Current.Clear(typeof(IMemberType)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); diff --git a/src/Umbraco.Web/Cache/DictionaryCacheRefresher.cs b/src/Umbraco.Web/Cache/DictionaryCacheRefresher.cs index 8e8236ad55..8209d247a2 100644 --- a/src/Umbraco.Web/Cache/DictionaryCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DictionaryCacheRefresher.cs @@ -2,7 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + namespace Umbraco.Web.Cache { @@ -28,21 +28,13 @@ namespace Umbraco.Web.Cache public override void Refresh(int id) { - //RuntimeCacheProvider.Current.Clear(typeof(IDictionaryItem)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); - //global::umbraco.cms.businesslogic.Dictionary.ClearCache(); - //when a dictionary item is updated we must also clear the text cache! - //global::umbraco.cms.businesslogic.language.Item.ClearCache(); base.Refresh(id); } public override void Remove(int id) { - //RuntimeCacheProvider.Current.Clear(typeof(IDictionaryItem)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); - //global::umbraco.cms.businesslogic.Dictionary.ClearCache(); - //when a dictionary item is removed we must also clear the text cache! - //global::umbraco.cms.businesslogic.language.Item.ClearCache(); base.Remove(id); } } diff --git a/src/Umbraco.Web/Cache/LanguageCacheRefresher.cs b/src/Umbraco.Web/Cache/LanguageCacheRefresher.cs index 43f69061cd..019be66b15 100644 --- a/src/Umbraco.Web/Cache/LanguageCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/LanguageCacheRefresher.cs @@ -2,7 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + namespace Umbraco.Web.Cache { @@ -28,17 +28,13 @@ namespace Umbraco.Web.Cache public override void Refresh(int id) { - //RuntimeCacheProvider.Current.Clear(typeof(ILanguage)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); base.Refresh(id); } public override void Remove(int id) { - //RuntimeCacheProvider.Current.Clear(typeof(ILanguage)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); - //when a language is removed we must also clear the text cache! - //global::umbraco.cms.businesslogic.language.Item.ClearCache(); base.Remove(id); } } diff --git a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs index 42c6063a70..a06501032f 100644 --- a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs @@ -4,7 +4,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; using umbraco; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using umbraco.interfaces; using System.Linq; @@ -176,7 +176,6 @@ namespace Umbraco.Web.Cache prefix => ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(prefix)); - //RuntimeCacheProvider.Current.Clear(typeof (IMacro)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); base.RefreshAll(); @@ -192,7 +191,6 @@ namespace Umbraco.Web.Cache alias => ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(alias)); - //RuntimeCacheProvider.Current.Delete(typeof(IMacro), payload.Id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(payload.Id)); }); diff --git a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs index 7e36989876..fd323c4bd1 100644 --- a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Cache; using Umbraco.Core.Events; using Umbraco.Core.IO; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using umbraco.interfaces; using System.Linq; @@ -171,7 +171,6 @@ namespace Umbraco.Web.Cache int idPartAsInt; if (int.TryParse(idPart, out idPartAsInt)) { - //RuntimeCacheProvider.Current.Delete(typeof(IMedia), idPartAsInt); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem( RepositoryBase.GetCacheIdKey(idPartAsInt)); } diff --git a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs index 58be13e72a..b57b3b343b 100644 --- a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs @@ -3,7 +3,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; -using Umbraco.Core.Persistence.Caching; + using umbraco.cms.businesslogic.member; using Umbraco.Core.Persistence.Repositories; using umbraco.interfaces; @@ -68,7 +68,6 @@ namespace Umbraco.Web.Cache ClearCacheByKeySearch(string.Format("{0}{1}", CacheKeys.MemberBusinessLogicCacheKey, id)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); - //RuntimeCacheProvider.Current.Delete(typeof(IMember), id); } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Cache/MemberGroupCacheRefresher.cs b/src/Umbraco.Web/Cache/MemberGroupCacheRefresher.cs index 460ed0d905..e410ab560c 100644 --- a/src/Umbraco.Web/Cache/MemberGroupCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MemberGroupCacheRefresher.cs @@ -4,7 +4,7 @@ using System.Web.Script.Serialization; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; namespace Umbraco.Web.Cache @@ -110,7 +110,6 @@ namespace Umbraco.Web.Cache { ApplicationContext.Current.ApplicationCache.RuntimeCache .ClearCacheByKeySearch(string.Format("{0}.{1}", typeof(IMemberGroup).FullName, payload.Name)); - //RuntimeCacheProvider.Current.Delete(typeof(IMemberGroup), payload.Id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(payload.Id)); } }); diff --git a/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs b/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs index 6cc3a1ab86..5ef1fbf468 100644 --- a/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs @@ -2,7 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + using umbraco; using umbraco.interfaces; @@ -60,7 +60,6 @@ namespace Umbraco.Web.Cache //need to clear the runtime cache for template instances //NOTE: This is temp until we implement the correct ApplicationCache and then we can remove the RuntimeCache, etc... - //RuntimeCacheProvider.Current.Clear(typeof(ITemplate)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); } diff --git a/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs b/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs index 41eb251e0f..1cf661a78f 100644 --- a/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs @@ -5,7 +5,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; using System.Linq; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Sync; @@ -77,14 +77,12 @@ namespace Umbraco.Web.Cache public override void RefreshAll() { - //RuntimeCacheProvider.Current.Clear(typeof(IContent)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); base.RefreshAll(); } public override void Refresh(int id) { - //RuntimeCacheProvider.Current.Delete(typeof(IContent), id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); content.Instance.UpdateSortOrder(id); base.Refresh(id); @@ -92,7 +90,6 @@ namespace Umbraco.Web.Cache public override void Remove(int id) { - //RuntimeCacheProvider.Current.Delete(typeof(IContent), id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); base.Remove(id); } @@ -100,7 +97,6 @@ namespace Umbraco.Web.Cache public override void Refresh(IContent instance) { - //RuntimeCacheProvider.Current.Delete(typeof(IContent), instance.Id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(instance.Id)); content.Instance.UpdateSortOrder(instance); base.Refresh(instance); @@ -108,7 +104,6 @@ namespace Umbraco.Web.Cache public override void Remove(IContent instance) { - //RuntimeCacheProvider.Current.Delete(typeof(IContent), instance.Id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(instance.Id)); base.Remove(instance); } @@ -121,7 +116,6 @@ namespace Umbraco.Web.Cache { foreach (var payload in DeserializeFromJsonPayload(jsonPayload)) { - //RuntimeCacheProvider.Current.Delete(typeof(IContent), payload.Id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(payload.Id)); content.Instance.UpdateSortOrder(payload.Id); } diff --git a/src/Umbraco.Web/Cache/UserCacheRefresher.cs b/src/Umbraco.Web/Cache/UserCacheRefresher.cs index eddefdaa98..95a7fdac49 100644 --- a/src/Umbraco.Web/Cache/UserCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/UserCacheRefresher.cs @@ -2,7 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models.Membership; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; using umbraco.interfaces; @@ -30,7 +30,6 @@ namespace Umbraco.Web.Cache public override void RefreshAll() { - //RuntimeCacheProvider.Current.Clear(typeof(IUser)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.UserPermissionsCacheKey); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.UserContextCacheKey); @@ -45,7 +44,6 @@ namespace Umbraco.Web.Cache public override void Remove(int id) { - //RuntimeCacheProvider.Current.Delete(typeof (IUser), id); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(string.Format("{0}{1}", CacheKeys.UserPermissionsCacheKey, id)); diff --git a/src/Umbraco.Web/Cache/UserTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/UserTypeCacheRefresher.cs index 22bbe7c216..2beaa4347d 100644 --- a/src/Umbraco.Web/Cache/UserTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/UserTypeCacheRefresher.cs @@ -2,7 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models.Membership; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Repositories; namespace Umbraco.Web.Cache @@ -30,21 +30,18 @@ namespace Umbraco.Web.Cache public override void RefreshAll() { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); - //RuntimeCacheProvider.Current.Clear(typeof (IUserType)); base.RefreshAll(); } public override void Refresh(int id) { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); - //RuntimeCacheProvider.Current.Delete(typeof(IUserType), id); base.Refresh(id); } public override void Remove(int id) { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); - //RuntimeCacheProvider.Current.Delete(typeof(IUserType), id); base.Remove(id); } diff --git a/src/umbraco.businesslogic/User.cs b/src/umbraco.businesslogic/User.cs index 3d0096da4b..e3349f6af6 100644 --- a/src/umbraco.businesslogic/User.cs +++ b/src/umbraco.businesslogic/User.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; using umbraco.DataLayer; @@ -822,7 +822,6 @@ namespace umbraco.BusinessLogic { OnFlushingFromCache(EventArgs.Empty); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); - //RuntimeCacheProvider.Current.Clear(typeof (IUser)); } /// diff --git a/src/umbraco.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs index 310439dad9..90091cc80e 100644 --- a/src/umbraco.cms/businesslogic/CMSNode.cs +++ b/src/umbraco.cms/businesslogic/CMSNode.cs @@ -7,7 +7,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Caching; + using umbraco.cms.businesslogic.web; using umbraco.DataLayer; using umbraco.BusinessLogic; @@ -607,10 +607,7 @@ order by level,sortOrder"; { c.Move(this); } - - //TODO: Properly refactor this, we're just clearing the cache so the changes will also be visible in the backoffice - InMemoryCacheProvider.Current.Clear(); - + FireAfterMove(e); } } diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 01a63f0625..cd4b65b7ba 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -10,7 +10,7 @@ using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.Caching; + using umbraco.cms.businesslogic.cache; using umbraco.cms.businesslogic.propertytype; using umbraco.cms.businesslogic.web; @@ -1203,9 +1203,7 @@ namespace umbraco.cms.businesslogic /// The id. public static void FlushFromCache(int id) { - //Ensure that MediaTypes are reloaded from db by clearing cache - InMemoryCacheProvider.Current.Clear(); - + var ct = new ContentType(id); ApplicationContext.Current.ApplicationCache.ClearCacheItem(string.Format("{0}{1}", CacheKeys.ContentTypeCacheKey, id)); ApplicationContext.Current.ApplicationCache.ClearCacheItem(ct.GetPropertiesCacheKey()); diff --git a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs index 4a2dc9e253..6e4b9a44da 100644 --- a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs +++ b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs @@ -6,7 +6,7 @@ using System.Threading; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Caching; + using umbraco.BusinessLogic; using umbraco.cms.businesslogic.cache; using umbraco.cms.businesslogic.property; @@ -465,8 +465,6 @@ namespace umbraco.cms.businesslogic.propertytype //Ensure that DocumentTypes are reloaded from db by clearing cache - this similar to the Save method on DocumentType. //NOTE Would be nice if we could clear cache by type instead of emptying the entire cache. - InMemoryCacheProvider.Current.Clear(); - //RuntimeCacheProvider.Current.Clear(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index a59039bea0..95d0f31a76 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -10,7 +10,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Logging; using Umbraco.Core.Models.EntityBase; -using Umbraco.Core.Persistence.Caching; + using Umbraco.Core.Publishing; using Umbraco.Core.Services; using umbraco.BusinessLogic; @@ -392,7 +392,6 @@ namespace umbraco.cms.businesslogic.web ApplicationContext.Current.DatabaseContext.Database.Execute( "update cmsDocument set templateId = NULL where templateId = @TemplateId", new {TemplateId = templateId}); //We need to clear cache for Documents since this is touching the database directly - //RuntimeCacheProvider.Current.Clear(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); }