mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
4da6654440
Added caching to ConfigFileProvider,
34 lines
742 B
C#
34 lines
742 B
C#
using System;
|
|
using NzbDrone.Common.EnsureThat;
|
|
|
|
namespace NzbDrone.Common.Cache
|
|
{
|
|
public interface ICacheManger
|
|
{
|
|
ICached<T> GetCache<T>(Type type);
|
|
ICached<T> GetCache<T>(object host);
|
|
}
|
|
|
|
public class CacheManger : ICacheManger
|
|
{
|
|
private readonly ICached<object> _cache;
|
|
|
|
public CacheManger()
|
|
{
|
|
_cache = new Cached<object>();
|
|
|
|
}
|
|
|
|
public ICached<T> GetCache<T>(Type type)
|
|
{
|
|
Ensure.That(() => type).IsNotNull();
|
|
|
|
return (ICached<T>)_cache.Get(type.FullName, () => new Cached<T>());
|
|
}
|
|
|
|
public ICached<T> GetCache<T>(object host)
|
|
{
|
|
return GetCache<T>(host.GetType());
|
|
}
|
|
}
|
|
} |