in src/Covi/Services/Storage/LiteDbStorage/StorageService.cs [104:133]
public async Task<T> GetAsync<T>(string key)
where T : class
{
return await Task.Run(async () =>
{
using (await _dbLock.LockAsync())
{
using (var db = await CreateAsync())
{
var result = default(T);
var collection = db.GetCollection<Entry>(key);
var entry = collection.FindAll().FirstOrDefault();
if (!string.IsNullOrEmpty(entry?.Payload))
{
try
{
var deserialized = await Serialization.Serializer.Instance.DeserializeAsync<T>(entry.Payload).ConfigureAwait(false);
result = deserialized;
}
catch (Exception ex)
{
_logger.LogError(ex, $"Failed to deserialize the {key} entity.");
}
}
return result;
}
}
}).ConfigureAwait(false);
}