mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-19 21:44:30 -04:00
Added Auth, startup options to UI
Added caching to ConfigFileProvider,
This commit is contained in:
@@ -3,20 +3,32 @@ using NzbDrone.Common.EnsureThat;
|
||||
|
||||
namespace NzbDrone.Common.Cache
|
||||
{
|
||||
public static class CacheManger
|
||||
public interface ICacheManger
|
||||
{
|
||||
private static readonly ICached<object> Cache;
|
||||
ICached<T> GetCache<T>(Type type);
|
||||
ICached<T> GetCache<T>(object host);
|
||||
}
|
||||
|
||||
static CacheManger()
|
||||
public class CacheManger : ICacheManger
|
||||
{
|
||||
private readonly ICached<object> _cache;
|
||||
|
||||
public CacheManger()
|
||||
{
|
||||
Cache = new Cached<object>();
|
||||
_cache = new Cached<object>();
|
||||
|
||||
}
|
||||
|
||||
public static ICached<T> GetCache<T>(Type type)
|
||||
public ICached<T> GetCache<T>(Type type)
|
||||
{
|
||||
Ensure.That(() => type).IsNotNull();
|
||||
|
||||
return (ICached<T>)Cache.Get(type.FullName, () => new Cached<T>());
|
||||
return (ICached<T>)_cache.Get(type.FullName, () => new Cached<T>());
|
||||
}
|
||||
|
||||
public ICached<T> GetCache<T>(object host)
|
||||
{
|
||||
return GetCache<T>(host.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
|
||||
namespace NzbDrone.Common.Cache
|
||||
@@ -16,7 +17,12 @@ namespace NzbDrone.Common.Cache
|
||||
public void Set(string key, T value)
|
||||
{
|
||||
Ensure.That(() => key).IsNotNullOrWhiteSpace();
|
||||
_store.TryAdd(key, value);
|
||||
_store[key] = value;
|
||||
}
|
||||
|
||||
public T Get(string key)
|
||||
{
|
||||
return Get(key, () => { throw new KeyNotFoundException(key); });
|
||||
}
|
||||
|
||||
public T Get(string key, Func<T> function)
|
||||
|
||||
@@ -9,5 +9,6 @@ namespace NzbDrone.Common.Cache
|
||||
bool ContainsKey(string key);
|
||||
void Clear();
|
||||
void Remove(string key);
|
||||
T Get(string key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user