From 1dc0352a082f416ac34d23fe878fd26d6c81a214 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Sat, 3 Feb 2024 21:46:17 +0100 Subject: [PATCH] Use IDistributedCache --- README.md | 19 ++++++------------- SampleApps/WpfApplication/MainWindow.xaml.cs | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 030de4e6..bc3f433c 100644 --- a/README.md +++ b/README.md @@ -30,28 +30,21 @@ which define the currently displayed map viewport. --- -The WPF version allows to use a System.Runtime.Caching.ObjectCache instance for caching map tile bitmaps. -The cache may be set to an instance of System.Runtime.Caching.MemoryCache (e.g. MemoryCache.Default), -but caching can also be done persistently by some specialized ObjectCache implementation. +The library allows to use a Microsoft.Extensions.Caching.Distributed.IDistributedCache instance for caching map tile bitmaps. + Map Control comes with three such implementations: -* ImageFileCache, an ObjectCache implementation that stores each cached map tile as a single image file, +* ImageFileCache, an IDistributedCache implementation that stores each cached map tile as a single image file, in the original file format delivered by the map provider (typically PNG or JPG). ImageFileCache is part of -the MapControl.WPF library. It does not support expiration, which means that cached tile image files will -not be deleted automatically. The cache may hence consume a considerable amount of disk space. -* FileDbCache, an ObjectCache implementation based on [EzTools FileDb](https://github.com/eztools-software/FileDb), +the MapControl library. +* FileDbCache, an IDistributedCache implementation based on [EzTools FileDb](https://github.com/eztools-software/FileDb), a simple, file based No-SQL database, in a separate library FileDbCache.WPF. -* SQLiteCache, an ObjectCache implementation based on [System.Data.SQLite](https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki), +* SQLiteCache, an IDistributedCache implementation based on [System.Data.SQLite](https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki), in a separate library SQLiteCache.WPF. If you want to try the sample application with persistent caching, uncomment the appropriate TileImageLoader.Cache setting in the sample application's MainWindow.xaml.cs file. Please note that some map providers may not allow persistent caching of their map data. -For UWP and WinUI, the cache functionality is defined by the interface IImageCache in the namespace MapControl.Caching, -and implemented by the classes ImageFileCache, FileDbCache (in library FileDbCache.UWP/.WinUI) and SQLiteCache -(in library SQLiteCache.UWP/.WinUI). -Local image files and database files are written to ApplicationData.Current.TemporaryFolder by default. - --- XAML Map Control is available on NuGet, with Package Id [XAML.MapControl](https://www.nuget.org/packages/XAML.MapControl/). diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index c166a75a..9d2cf10d 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -16,7 +16,7 @@ namespace SampleApplication { static MainWindow() { - TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder); + //TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new SQLiteCache(TileImageLoader.DefaultCacheFolder);