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.Runtime.InteropServices.WindowsRuntime;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Windows.Storage.Streams;
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
{
|
|
|
|
|
|
Buffer = ((byte[])record[0]).AsBuffer(),
|
|
|
|
|
|
Expiration = (DateTime)record[1]
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task SetAsync(string key, IBuffer buffer, DateTime expiration)
|
|
|
|
|
|
{
|
2019-07-22 19:47:57 +02:00
|
|
|
|
return Task.Run(() => AddOrUpdateRecord(key, buffer?.ToArray(), expiration));
|
2019-07-21 00:17:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|