mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Clean/CleanAsync in cache implementations
This commit is contained in:
parent
7ab95c3bed
commit
cdb7d4af15
3 changed files with 76 additions and 49 deletions
|
|
@ -38,11 +38,8 @@ namespace MapControl.Caching
|
|||
rootDirectory = directory;
|
||||
|
||||
Debug.WriteLine($"Created ImageFileCache in {rootDirectory}");
|
||||
}
|
||||
|
||||
public Task CleanAsync()
|
||||
{
|
||||
return Task.Factory.StartNew(CleanRootDirectory, TaskCreationOptions.LongRunning);
|
||||
ThreadPool.QueueUserWorkItem(o => Clean());
|
||||
}
|
||||
|
||||
public byte[] Get(string key)
|
||||
|
|
@ -253,21 +250,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
}
|
||||
|
||||
private string GetPath(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.Combine(rootDirectory, Path.Combine(key.Split('/')));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"ImageFileCache: Invalid key {rootDirectory}/{key}: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void CleanRootDirectory()
|
||||
public void Clean()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -287,6 +270,25 @@ namespace MapControl.Caching
|
|||
}
|
||||
}
|
||||
|
||||
public Task CleanAsync()
|
||||
{
|
||||
return Task.Factory.StartNew(Clean, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
|
||||
private string GetPath(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.Combine(rootDirectory, Path.Combine(key.Split('/')));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"ImageFileCache: Invalid key {rootDirectory}/{key}: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int CleanDirectory(DirectoryInfo directory)
|
||||
{
|
||||
var deletedFileCount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue