mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
Version 2.7.1. Fixed minor issues with caching.
This commit is contained in:
parent
5adcd6568e
commit
ed271719f8
19 changed files with 136 additions and 142 deletions
|
|
@ -81,7 +81,7 @@ namespace MapControl.Caching
|
|||
try
|
||||
{
|
||||
fileDb.Open(path, false);
|
||||
Debug.WriteLine("FileDbCache: Opened database with {0} cached items in {1}.", fileDb.NumRecords, path);
|
||||
Debug.WriteLine("FileDbCache: Opened database with {0} cached items in {1}", fileDb.NumRecords, path);
|
||||
|
||||
Clean();
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.NumRecords failed: {0}", (object)ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.NumRecords: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,20 +248,20 @@ namespace MapControl.Caching
|
|||
|
||||
if (fileDb.IsOpen)
|
||||
{
|
||||
var expires = DateTime.MaxValue;
|
||||
var expiration = DateTime.MaxValue;
|
||||
|
||||
if (policy.AbsoluteExpiration != InfiniteAbsoluteExpiration)
|
||||
{
|
||||
expires = policy.AbsoluteExpiration.DateTime;
|
||||
expiration = policy.AbsoluteExpiration.DateTime;
|
||||
}
|
||||
else if (policy.SlidingExpiration != NoSlidingExpiration)
|
||||
{
|
||||
expires = DateTime.UtcNow + policy.SlidingExpiration;
|
||||
expiration = DateTime.UtcNow + policy.SlidingExpiration;
|
||||
}
|
||||
|
||||
if (!AddOrUpdateRecord(key, value, expires) && RepairDatabase())
|
||||
if (!AddOrUpdateRecord(key, value, expiration) && RepairDatabase())
|
||||
{
|
||||
AddOrUpdateRecord(key, value, expires);
|
||||
AddOrUpdateRecord(key, value, expiration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.DeleteRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.DeleteRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -335,11 +335,11 @@ namespace MapControl.Caching
|
|||
{
|
||||
if (fileDb.IsOpen)
|
||||
{
|
||||
fileDb.DeleteRecords(new FilterExpression(expiresField, DateTime.UtcNow, ComparisonOperatorEnum.LessThan));
|
||||
int deleted = fileDb.DeleteRecords(new FilterExpression(expiresField, DateTime.UtcNow, ComparisonOperatorEnum.LessThan));
|
||||
|
||||
if (fileDb.NumDeleted > 0)
|
||||
if (deleted > 0)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: Deleted {0} expired items.", fileDb.NumDeleted);
|
||||
Debug.WriteLine("FileDbCache: Deleted {0} expired items", deleted);
|
||||
fileDb.Clean();
|
||||
}
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ namespace MapControl.Caching
|
|||
new Field(expiresField, DataTypeEnum.DateTime)
|
||||
});
|
||||
|
||||
Debug.WriteLine("FileDbCache: Created database {0}.", (object)path);
|
||||
Debug.WriteLine("FileDbCache: Created database " + path);
|
||||
}
|
||||
|
||||
private bool RepairDatabase()
|
||||
|
|
@ -385,7 +385,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.Reindex() failed: {0}", (object)ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.Reindex(): " + ex.Message);
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -395,17 +395,17 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: Creating database {0} failed: {1}", path, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: Creating database {0}: {1}", path, ex.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool AddOrUpdateRecord(string key, object value, DateTime expires)
|
||||
private bool AddOrUpdateRecord(string key, object value, DateTime expiration)
|
||||
{
|
||||
var fieldValues = new FieldValues(3);
|
||||
fieldValues.Add(valueField, value);
|
||||
fieldValues.Add(expiresField, expires);
|
||||
fieldValues.Add(expiresField, expiration);
|
||||
|
||||
bool recordExists;
|
||||
|
||||
|
|
@ -415,7 +415,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.UpdateRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.UpdateRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -440,11 +440,12 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.AddRecord(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.AddRecord(\"{0}\"): {1}", key, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Debug.WriteLine("FileDbCache: Writing \"{0}\", Expires {1}", key, expiration.ToLocalTime());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.7.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.0")]
|
||||
[assembly: AssemblyVersion("2.7.1")]
|
||||
[assembly: AssemblyFileVersion("2.7.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ namespace MapControl.Caching
|
|||
{
|
||||
if (fileDb.IsOpen)
|
||||
{
|
||||
fileDb.DeleteRecords(new FilterExpression(expiresField, DateTime.UtcNow, ComparisonOperatorEnum.LessThan));
|
||||
int deleted = fileDb.DeleteRecords(new FilterExpression(expiresField, DateTime.UtcNow, ComparisonOperatorEnum.LessThan));
|
||||
|
||||
if (fileDb.NumDeleted > 0)
|
||||
if (deleted > 0)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: Deleted {0} expired items.", fileDb.NumDeleted);
|
||||
Debug.WriteLine("FileDbCache: Deleted {0} expired items", deleted);
|
||||
fileDb.Clean();
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ namespace MapControl.Caching
|
|||
return await Task.Run(() => Get(key));
|
||||
}
|
||||
|
||||
public async Task SetAsync(string key, IBuffer buffer, DateTime expires)
|
||||
public async Task SetAsync(string key, IBuffer buffer, DateTime expiration)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
|
|
@ -103,11 +103,11 @@ namespace MapControl.Caching
|
|||
if (fileDb.IsOpen)
|
||||
{
|
||||
var bytes = buffer.ToArray();
|
||||
var ok = await Task.Run(() => AddOrUpdateRecord(key, bytes, expires));
|
||||
var ok = await Task.Run(() => AddOrUpdateRecord(key, bytes, expiration));
|
||||
|
||||
if (!ok && (await RepairDatabase()))
|
||||
{
|
||||
await Task.Run(() => AddOrUpdateRecord(key, bytes, expires));
|
||||
await Task.Run(() => AddOrUpdateRecord(key, bytes, expiration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ namespace MapControl.Caching
|
|||
var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
|
||||
|
||||
fileDb.Open(stream.AsStream());
|
||||
Debug.WriteLine("FileDbCache: Opened database with {0} cached items in {1}.", fileDb.NumRecords, file.Path);
|
||||
Debug.WriteLine("FileDbCache: Opened database with {0} cached items in {1}", fileDb.NumRecords, file.Path);
|
||||
|
||||
Clean();
|
||||
return;
|
||||
|
|
@ -157,7 +157,7 @@ namespace MapControl.Caching
|
|||
new Field(expiresField, DataTypeEnum.DateTime)
|
||||
});
|
||||
|
||||
Debug.WriteLine("FileDbCache: Created database {0}.", file.Path);
|
||||
Debug.WriteLine("FileDbCache: Created database " + file.Path);
|
||||
}
|
||||
|
||||
private async Task<bool> RepairDatabase()
|
||||
|
|
@ -169,7 +169,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.Reindex() failed: {0}", ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.Reindex(): " + ex.Message);
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -179,7 +179,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: Creating database {0} failed: {1}", Path.Combine(folder.Path, name), ex.Message);
|
||||
Debug.WriteLine("FileDbCache: Creating database {0}: {1}", Path.Combine(folder.Path, name), ex.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -188,50 +188,33 @@ namespace MapControl.Caching
|
|||
private ImageCacheItem Get(string key)
|
||||
{
|
||||
var fields = new string[] { valueField, expiresField };
|
||||
Record record = null;
|
||||
|
||||
try
|
||||
{
|
||||
record = fileDb.GetRecordByKey(key, fields, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
}
|
||||
var record = fileDb.GetRecordByKey(key, fields, false);
|
||||
|
||||
if (record != null)
|
||||
{
|
||||
try
|
||||
if (record != null)
|
||||
{
|
||||
return new ImageCacheItem
|
||||
{
|
||||
Buffer = ((byte[])record[0]).AsBuffer(),
|
||||
Expires = (DateTime)record[1]
|
||||
Expiration = (DateTime)record[1]
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: Decoding \"{0}\" failed: {1}", key, ex.Message);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
fileDb.DeleteRecordByKey(key);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.DeleteRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool AddOrUpdateRecord(string key, byte[] value, DateTime expires)
|
||||
private bool AddOrUpdateRecord(string key, byte[] value, DateTime expiration)
|
||||
{
|
||||
var fieldValues = new FieldValues(3);
|
||||
fieldValues.Add(valueField, value);
|
||||
fieldValues.Add(expiresField, expires);
|
||||
fieldValues.Add(expiresField, expiration);
|
||||
|
||||
bool recordExists;
|
||||
|
||||
|
|
@ -241,7 +224,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.GetRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +236,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.UpdateRecordByKey(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.UpdateRecordByKey(\"{0}\"): {1}", key, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -266,12 +249,12 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("FileDbCache: FileDb.AddRecord(\"{0}\") failed: {1}", key, ex.Message);
|
||||
Debug.WriteLine("FileDbCache: FileDb.AddRecord(\"{0}\"): {1}", key, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Debug.WriteLine("Cached item {0}, expires {1}", key, expires);
|
||||
//Debug.WriteLine("FileDbCache: Writing \"{0}\", Expires {1}", key, expiration.ToLocalTime());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.7.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.0")]
|
||||
[assembly: AssemblyVersion("2.7.1")]
|
||||
[assembly: AssemblyFileVersion("2.7.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -22,13 +22,12 @@ namespace MapControl.Caching
|
|||
{
|
||||
private static readonly Tuple<string, byte[]>[] imageFileTypes = new Tuple<string, byte[]>[]
|
||||
{
|
||||
new Tuple<string, byte[]>(".png", new byte[] { 0x89, 0x50, 0x4E, 0x47, 0xD, 0xA, 0x1A, 0xA }),
|
||||
new Tuple<string, byte[]>(".jpg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE0, 0, 0x10, 0x4A, 0x46, 0x49, 0x46, 0 }),
|
||||
new Tuple<string, byte[]>(".png", new byte[] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }),
|
||||
new Tuple<string, byte[]>(".jpg", new byte[] { 0xFF, 0xD8, 0xFF }),
|
||||
new Tuple<string, byte[]>(".bmp", new byte[] { 0x42, 0x4D }),
|
||||
new Tuple<string, byte[]>(".gif", new byte[] { 0x47, 0x49, 0x46 }),
|
||||
new Tuple<string, byte[]>(".tif", new byte[] { 0x49, 0x49, 42, 0 }),
|
||||
new Tuple<string, byte[]>(".tif", new byte[] { 0x4D, 0x4D, 0, 42 }),
|
||||
new Tuple<string, byte[]>(".wdp", new byte[] { 0x49, 0x49, 0xBC }),
|
||||
new Tuple<string, byte[]>(".tif", new byte[] { 0x49, 0x49, 0x2A, 0x00 }),
|
||||
new Tuple<string, byte[]>(".tif", new byte[] { 0x4D, 0x4D, 0x00, 0x2A }),
|
||||
new Tuple<string, byte[]>(".bin", new byte[] { }),
|
||||
};
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ namespace MapControl.Caching
|
|||
rootFolder = Path.Combine(folder, name);
|
||||
Directory.CreateDirectory(rootFolder);
|
||||
|
||||
Debug.WriteLine("Created ImageFileCache in {0}.", (object)rootFolder);
|
||||
Debug.WriteLine("Created ImageFileCache in " + rootFolder);
|
||||
}
|
||||
|
||||
public override string Name
|
||||
|
|
@ -132,12 +131,13 @@ namespace MapControl.Caching
|
|||
{
|
||||
try
|
||||
{
|
||||
//Debug.WriteLine("ImageFileCache: Reading " + path);
|
||||
buffer = File.ReadAllBytes(path);
|
||||
memoryCache.Set(key, buffer, new CacheItemPolicy());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageFileCache: Writing file {0} failed: {1}", path, ex.Message);
|
||||
Debug.WriteLine("ImageFileCache: Reading {0}: {1}", path, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -183,6 +183,7 @@ namespace MapControl.Caching
|
|||
|
||||
try
|
||||
{
|
||||
//Debug.WriteLine("ImageFileCache: Writing {0}, Expires {1}", path, policy.AbsoluteExpiration.DateTime.ToLocalTime());
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
File.WriteAllBytes(path, buffer);
|
||||
|
||||
|
|
@ -192,7 +193,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageFileCache: Writing file {0} failed: {1}", path, ex.Message);
|
||||
Debug.WriteLine("ImageFileCache: Writing {0}: {1}", path, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +254,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageFileCache: Removing file {0} failed: {1}", path, ex.Message);
|
||||
Debug.WriteLine("ImageFileCache: Removing {0}: {1}", path, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +281,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageFileCache: Finding file {0} failed: {1}", path, ex.Message);
|
||||
Debug.WriteLine("ImageFileCache: Finding {0}: {1}", path, ex.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.7.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.0")]
|
||||
[assembly: AssemblyVersion("2.7.1")]
|
||||
[assembly: AssemblyFileVersion("2.7.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace MapControl.Caching
|
|||
folder.CreateFolderAsync(name, CreationCollisionOption.OpenIfExists).Completed = (o, s) =>
|
||||
{
|
||||
rootFolder = o.GetResults();
|
||||
Debug.WriteLine("Created ImageFileCache in {0}.", rootFolder.Path);
|
||||
Debug.WriteLine("Created ImageFileCache in " + rootFolder.Path);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -43,26 +43,26 @@ namespace MapControl.Caching
|
|||
if (item != null && item.IsOfType(StorageItemTypes.File))
|
||||
{
|
||||
var file = (StorageFile)item;
|
||||
//Debug.WriteLine("ImageFileCache: Reading file {0}", file.Path);
|
||||
//Debug.WriteLine("ImageFileCache: Reading " + file.Path);
|
||||
|
||||
try
|
||||
{
|
||||
return new ImageCacheItem
|
||||
{
|
||||
Buffer = await FileIO.ReadBufferAsync(file),
|
||||
Expires = (await file.Properties.GetImagePropertiesAsync()).DateTaken.UtcDateTime
|
||||
Expiration = (await file.Properties.GetImagePropertiesAsync()).DateTaken.UtcDateTime
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageFileCache: Reading file {0} failed: {1}", file.Path, ex.Message);
|
||||
Debug.WriteLine("ImageFileCache: Reading {0}: {1}", file.Path, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task SetAsync(string key, IBuffer buffer, DateTime expires)
|
||||
public virtual async Task SetAsync(string key, IBuffer buffer, DateTime expiration)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -75,18 +75,18 @@ namespace MapControl.Caching
|
|||
}
|
||||
|
||||
var file = await folder.CreateFileAsync(names[names.Length - 1], CreationCollisionOption.ReplaceExisting);
|
||||
//Debug.WriteLine("ImageFileCache: Writing file {0}", file.Path);
|
||||
//Debug.WriteLine("ImageFileCache: Writing {0}, Expires {1}", file.Path, expiration.ToLocalTime());
|
||||
|
||||
await FileIO.WriteBufferAsync(file, buffer);
|
||||
|
||||
// Store expiration date in ImageProperties.DateTaken
|
||||
var properties = await file.Properties.GetImagePropertiesAsync();
|
||||
properties.DateTaken = expires;
|
||||
properties.DateTaken = expiration;
|
||||
await properties.SavePropertiesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageFileCache: Writing file {0}\\{1} failed: {2}", rootFolder.Path, key, ex.Message);
|
||||
Debug.WriteLine("ImageFileCache: Writing {0}\\{1}: {2}", rootFolder.Path, key, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("2.7.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.0")]
|
||||
[assembly: AssemblyVersion("2.7.1")]
|
||||
[assembly: AssemblyFileVersion("2.7.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue