using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Cache
{
///
/// Implements by wrapping an inner other
/// instance, and ensuring that all inserts and returns are deep cloned copies of the cache item,
/// when the item is deep-cloneable.
///
internal class DeepCloneAppCache : IAppPolicyCache
{
///
/// Initializes a new instance of the class.
///
public DeepCloneAppCache(IAppPolicyCache innerCache)
{
var type = typeof (DeepCloneAppCache);
if (innerCache.GetType() == type)
throw new InvalidOperationException($"A {type} cannot wrap another instance of itself.");
InnerCache = innerCache;
}
///
/// Gets the inner cache.
///
public IAppPolicyCache InnerCache { get; }
///
public object Get(string key)
{
var item = InnerCache.Get(key);
return CheckCloneableAndTracksChanges(item);
}
///
public object Get(string key, Func