mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-10 00:45:13 +00:00
Version 7.0: WinUI
This commit is contained in:
parent
0820a77dd5
commit
63da15f6a5
32 changed files with 57 additions and 149 deletions
50
SQLiteCache/WinUI/SQLiteCache.WinUI.cs
Normal file
50
SQLiteCache/WinUI/SQLiteCache.WinUI.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2021 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapControl.Caching
|
||||
{
|
||||
public partial class SQLiteCache : IImageCache
|
||||
{
|
||||
public async Task<Tuple<byte[], DateTime>> GetAsync(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var command = GetItemCommand(key))
|
||||
{
|
||||
var reader = await command.ExecuteReaderAsync();
|
||||
|
||||
if (await reader.ReadAsync())
|
||||
{
|
||||
return Tuple.Create((byte[])reader["buffer"], new DateTime((long)reader["expiration"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"SQLiteCache.GetAsync({key}): {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task SetAsync(string key, byte[] buffer, DateTime expiration)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var command = SetItemCommand(key, buffer, expiration))
|
||||
{
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"SQLiteCache.SetAsync({key}): {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue