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

33 lines
861 B
C#
Raw Normal View History

2019-07-21 00:17:16 +02:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2022-01-14 20:22:56 +01:00
// © 2022 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
{
2021-07-02 15:57:01 +02:00
public Task<Tuple<byte[], DateTime>> GetAsync(string key)
2019-07-21 00:17:16 +02:00
{
return Task.Run(() =>
{
var record = GetRecordByKey(key);
if (record == null)
{
return null;
}
2021-07-02 15:57:01 +02:00
return Tuple.Create((byte[])record[0], (DateTime)record[1]);
2019-07-21 00:17:16 +02:00
});
}
2021-07-02 15:57:01 +02:00
public Task SetAsync(string key, byte[] buffer, DateTime expiration)
2019-07-21 00:17:16 +02:00
{
2021-07-02 15:57:01 +02:00
return Task.Run(() => AddOrUpdateRecord(key, buffer, expiration));
2019-07-21 00:17:16 +02:00
}
}
}