mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update SQLiteCache.cs
This commit is contained in:
parent
24c6bd34c8
commit
cd25eaf4bf
|
|
@ -182,13 +182,21 @@ namespace MapControl.Caching
|
||||||
|
|
||||||
public void DeleteExpiredItems()
|
public void DeleteExpiredItems()
|
||||||
{
|
{
|
||||||
using (var command = DeleteExpiredItemCommand())
|
long deleted;
|
||||||
|
|
||||||
|
using (var command = DeleteExpiredItemsCommand())
|
||||||
{
|
{
|
||||||
var deleted = (long)command.ExecuteScalar();
|
deleted = (long)command.ExecuteScalar();
|
||||||
|
}
|
||||||
|
|
||||||
if (deleted > 0)
|
if (deleted > 0)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"{nameof(SQLiteCache)}: Deleted {deleted} expired items");
|
using (var command = new SQLiteCommand("vacuum", connection))
|
||||||
|
{
|
||||||
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.WriteLine($"{nameof(SQLiteCache)}: Deleted {deleted} expired items");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,7 +227,7 @@ namespace MapControl.Caching
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteCommand DeleteExpiredItemCommand()
|
private SQLiteCommand DeleteExpiredItemsCommand()
|
||||||
{
|
{
|
||||||
var command = new SQLiteCommand("delete from items where expiration <= @exp; select changes()", connection);
|
var command = new SQLiteCommand("delete from items where expiration <= @exp; select changes()", connection);
|
||||||
command.Parameters.AddWithValue("@exp", DateTimeOffset.UtcNow.Ticks);
|
command.Parameters.AddWithValue("@exp", DateTimeOffset.UtcNow.Ticks);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue