using System; using System.Collections.Generic; using NzbDrone.Common.EnsureThat; namespace NzbDrone.Common.Cache { public interface ICacheManger { ICached GetCache(Type host, string name); ICached GetCache(Type host); //ICollection> Caches { get;} void Clear(); ICollection Caches { get; } } public class CacheManger : ICacheManger { private readonly ICached _cache; public CacheManger() { _cache = new Cached(); } public ICached GetCache(Type host) { Ensure.That(() => host).IsNotNull(); return GetCache(host, host.FullName); } public void Clear() { _cache.Clear(); } public ICollection Caches { get { return _cache.Values; } } public ICached GetCache(Type host, string name) { Ensure.That(() => host).IsNotNull(); Ensure.That(() => name).IsNotNullOrWhiteSpace(); return (ICached)_cache.Get(host.FullName + "_" + name, () => new Cached()); } } }