Files
mixtape/zero.Core/Stores/StoreCache.cs
T
2021-11-24 13:56:08 +01:00

39 lines
652 B
C#

using System.Collections.Concurrent;
namespace zero.Stores;
public class StoreCache : IStoreCache
{
protected ConcurrentDictionary<string, object> _cache = new();
public StoreCache()
{
}
public bool TryGetValue<T>(string id, out T model)
{
if (_cache.TryGetValue(id, out object modelObj))
{
model = (T)modelObj;
return true;
}
model = default;
return false;
}
//public IStoreCache For(CachableEntityStoreOptions options)
//{
// return this;
//}
}
public interface IStoreCache
{
//IStoreCache For(CachableEntityStoreOptions options);
bool TryGetValue<T>(string id, out T model);
}