failsafe load dlls

add user config queue offsets
throttle improvements
This commit is contained in:
Alex Bezdieniezhnykh
2025-04-17 01:19:48 +03:00
parent 0237e279a5
commit 0c66607ed7
32 changed files with 320 additions and 188 deletions
+27
View File
@@ -0,0 +1,27 @@
using LazyCache;
namespace Azaion.CommonSecurity.Services;
public interface ICache
{
T GetFromCache<T>(string key, Func<T> fetchFunc, TimeSpan? expiration = null);
void Invalidate(string key);
}
public class MemoryCache : ICache
{
private readonly IAppCache _cache = new CachingService();
public T GetFromCache<T>(string key, Func<T> fetchFunc, TimeSpan? expiration = null)
{
expiration ??= TimeSpan.FromHours(4);
return _cache.GetOrAdd(key, entry =>
{
var result = fetchFunc();
entry.AbsoluteExpirationRelativeToNow = expiration;
return result;
});
}
public void Invalidate(string key) => _cache.Remove(key);
}