mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
non-working cached repository.
This commit is contained in:
parent
23e9c725f3
commit
5b2410da3f
6 changed files with 92 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
|
||||
namespace NzbDrone.Common.Cache
|
||||
|
@ -7,15 +8,18 @@ namespace NzbDrone.Common.Cache
|
|||
{
|
||||
ICached<T> GetCache<T>(Type host, string name);
|
||||
ICached<T> GetCache<T>(Type host);
|
||||
//ICollection<ICached<T>> Caches<T> { get;}
|
||||
void Clear();
|
||||
ICollection<ICached> Caches { get; }
|
||||
}
|
||||
|
||||
public class CacheManger : ICacheManger
|
||||
{
|
||||
private readonly ICached<object> _cache;
|
||||
private readonly ICached<ICached> _cache;
|
||||
|
||||
public CacheManger()
|
||||
{
|
||||
_cache = new Cached<object>();
|
||||
_cache = new Cached<ICached>();
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,6 +29,14 @@ namespace NzbDrone.Common.Cache
|
|||
return GetCache<T>(host, host.FullName);
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
|
||||
public ICollection<ICached> Caches { get { return _cache.Values; } }
|
||||
|
||||
public ICached<T> GetCache<T>(Type host, string name)
|
||||
{
|
||||
Ensure.That(() => host).IsNotNull();
|
||||
|
|
|
@ -64,5 +64,20 @@ namespace NzbDrone.Common.Cache
|
|||
T value;
|
||||
_store.TryRemove(key, out value);
|
||||
}
|
||||
|
||||
public ICollection<T> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return _store.Values;
|
||||
}
|
||||
}
|
||||
public ICollection<string> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return _store.Keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Common.Cache
|
||||
{
|
||||
public interface ICached<T>
|
||||
public interface ICached
|
||||
{
|
||||
void Set(string key, T value);
|
||||
T Get(string key, Func<T> function);
|
||||
bool ContainsKey(string key);
|
||||
void Clear();
|
||||
void Remove(string key);
|
||||
}
|
||||
|
||||
public interface ICached<T> : ICached
|
||||
{
|
||||
void Set(string key, T value);
|
||||
T Get(string key, Func<T> function);
|
||||
T Get(string key);
|
||||
T Find(string key);
|
||||
|
||||
ICollection<T> Values { get; }
|
||||
ICollection<string> Keys { get; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue