XAML-Map-Control/FileDbCache/UWP/FileDbCache.UWP.cs

37 lines
965 B
C#
Raw Normal View History

2019-07-21 00:17:16 +02:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2021-01-13 21:19:27 +01:00
// © 2021 Clemens Fischer
2019-07-21 00:17:16 +02:00
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.Threading.Tasks;
namespace MapControl.Caching
{
public partial class FileDbCache : IImageCache
{
public Task<ImageCacheItem> GetAsync(string key)
{
return Task.Run(() =>
{
var record = GetRecordByKey(key);
if (record == null)
{
return null;
}
return new ImageCacheItem
{
2021-07-02 11:35:20 +02:00
Buffer = (byte[])record[0],
2019-07-21 00:17:16 +02:00
Expiration = (DateTime)record[1]
};
});
}
2021-07-02 11:35:20 +02:00
public Task SetAsync(string key, ImageCacheItem cacheItem)
2019-07-21 00:17:16 +02:00
{
2021-07-02 11:35:20 +02:00
return Task.Run(() => AddOrUpdateRecord(key, cacheItem.Buffer, cacheItem.Expiration));
2019-07-21 00:17:16 +02:00
}
}
}