mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
ImageFileCache trace output
This commit is contained in:
parent
ad84894b47
commit
1e220b36e2
|
|
@ -90,6 +90,8 @@ namespace MapControl.Caching
|
|||
var options = new DistributedCacheEntryOptions { AbsoluteExpiration = file.CreationTime };
|
||||
|
||||
memoryCache.Set(key, value, options);
|
||||
|
||||
logger?.LogTrace("Read {name}", file.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -123,6 +125,8 @@ namespace MapControl.Caching
|
|||
var options = new DistributedCacheEntryOptions { AbsoluteExpiration = file.CreationTime };
|
||||
|
||||
await memoryCache.SetAsync(key, value, options, token).ConfigureAwait(false);
|
||||
|
||||
logger?.LogTrace("Read {name}", file.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -155,6 +159,8 @@ namespace MapControl.Caching
|
|||
}
|
||||
|
||||
SetExpiration(file, options);
|
||||
|
||||
logger?.LogTrace("Wrote {name}", file.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -184,6 +190,8 @@ namespace MapControl.Caching
|
|||
}
|
||||
|
||||
SetExpiration(file, options);
|
||||
|
||||
logger?.LogTrace("Wrote {name}", file.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
#if WPF
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if WPF
|
||||
using System.Windows.Media;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml.Media;
|
||||
#elif WINUI
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
|
|
@ -127,7 +134,9 @@ namespace MapControl
|
|||
|
||||
if (string.IsNullOrEmpty(cacheName))
|
||||
{
|
||||
await LoadTileImage(tile, () => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel)).ConfigureAwait(false);
|
||||
Task<ImageSource> LoadImage() => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel);
|
||||
|
||||
await LoadTileImage(tile, LoadImage).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -139,7 +148,9 @@ namespace MapControl
|
|||
|
||||
if (buffer != null && buffer.Length > 0)
|
||||
{
|
||||
await LoadTileImage(tile, () => tileSource.LoadImageAsync(buffer)).ConfigureAwait(false);
|
||||
Task<ImageSource> LoadImage() => tileSource.LoadImageAsync(buffer);
|
||||
|
||||
await LoadTileImage(tile, LoadImage).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +171,7 @@ namespace MapControl
|
|||
|
||||
try
|
||||
{
|
||||
buffer = await Cache.GetAsync(cacheKey);
|
||||
buffer = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -173,18 +184,20 @@ namespace MapControl
|
|||
|
||||
if (response != null)
|
||||
{
|
||||
buffer = response.Buffer;
|
||||
buffer = response.Buffer ?? Array.Empty<byte>(); // cache even if null, when no tile available
|
||||
|
||||
try
|
||||
{
|
||||
var expiration = !response.MaxAge.HasValue ? DefaultCacheExpiration
|
||||
var options = new DistributedCacheEntryOptions
|
||||
{
|
||||
AbsoluteExpirationRelativeToNow =
|
||||
!response.MaxAge.HasValue ? DefaultCacheExpiration
|
||||
: response.MaxAge.Value < MinCacheExpiration ? MinCacheExpiration
|
||||
: response.MaxAge.Value > MaxCacheExpiration ? MaxCacheExpiration
|
||||
: response.MaxAge.Value;
|
||||
: response.MaxAge.Value
|
||||
};
|
||||
|
||||
await Cache.SetAsync(cacheKey,
|
||||
buffer ?? Array.Empty<byte>(), // cache even if null, when no tile available
|
||||
new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = expiration });
|
||||
await Cache.SetAsync(cacheKey, buffer, options).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue