mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Cyclic clean
This commit is contained in:
parent
df4b330d08
commit
d31f522c52
2 changed files with 23 additions and 3 deletions
|
|
@ -19,8 +19,14 @@ namespace MapControl.Caching
|
|||
public sealed class SQLiteCache : IDistributedCache, IDisposable
|
||||
{
|
||||
private readonly SQLiteConnection connection;
|
||||
private readonly Timer cleanTimer;
|
||||
|
||||
public SQLiteCache(string path)
|
||||
: this(path, TimeSpan.FromHours(1))
|
||||
{
|
||||
}
|
||||
|
||||
public SQLiteCache(string path, TimeSpan autoCleanInterval)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
|
|
@ -42,11 +48,15 @@ namespace MapControl.Caching
|
|||
|
||||
Debug.WriteLine($"{nameof(SQLiteCache)}: Opened database {path}");
|
||||
|
||||
Clean();
|
||||
if (autoCleanInterval > TimeSpan.Zero)
|
||||
{
|
||||
cleanTimer = new Timer(_ => Clean(), null, TimeSpan.Zero, autoCleanInterval);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
cleanTimer?.Dispose();
|
||||
connection.Dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue