diff --git a/src/ImageProcessor.Web/Caching/PersistantDictionary.cs b/src/ImageProcessor.Web/Caching/PersistantDictionary.cs
index 5d1ce3616d..aaa8f7c0ba 100644
--- a/src/ImageProcessor.Web/Caching/PersistantDictionary.cs
+++ b/src/ImageProcessor.Web/Caching/PersistantDictionary.cs
@@ -131,7 +131,7 @@ namespace ImageProcessor.Web.Caching
{
if (remove)
{
- return await SQLContext.RemoveImageAsync(key);
+ return await SQLContext.RemoveImageAsync(cachedImage);
}
return await SQLContext.AddImageAsync(cachedImage);
diff --git a/src/ImageProcessor.Web/Caching/SQLContext.cs b/src/ImageProcessor.Web/Caching/SQLContext.cs
index dd939d4640..4d2bb39833 100644
--- a/src/ImageProcessor.Web/Caching/SQLContext.cs
+++ b/src/ImageProcessor.Web/Caching/SQLContext.cs
@@ -45,7 +45,6 @@ namespace ImageProcessor.Web.Caching
#region Methods
#region Internal
-
///
/// Creates the database if it doesn't already exist.
///
@@ -120,49 +119,12 @@ namespace ImageProcessor.Web.Caching
/// The true if the addition of the cached image is added; otherwise, false.
///
internal static async Task AddImageAsync(CachedImage image)
- {
- // Create Action delegate for AddImage.
- return await TaskHelpers.Run(() => AddImage(image));
- }
-
- ///
- /// Removes a cached image from the database.
- ///
- ///
- /// The key for the cached image.
- ///
- ///
- /// The true if the addition of the cached image is removed; otherwise, false.
- ///
- internal static async Task RemoveImageAsync(string key)
- {
- // Create Action delegate for RemoveImage.
- return await TaskHelpers.Run(() => RemoveImage(key));
- }
- #endregion
-
- #region Private
-
- ///
- /// Adds a cached image to the database.
- ///
- ///
- /// The cached image to add.
- ///
- ///
- /// The true if the addition of the cached image is added; otherwise, false.
- ///
- private static int AddImage(CachedImage image)
{
try
{
- int id = 0;
- SQLiteConnection connection = new SQLiteConnection(ConnectionString);
-
- id = connection.Insert(image);
- connection.Dispose();
+ SQLiteAsyncConnection connection = new SQLiteAsyncConnection(ConnectionString);
- return id;
+ return await connection.InsertAsync(image);
}
catch
{
@@ -173,23 +135,19 @@ namespace ImageProcessor.Web.Caching
///
/// Removes a cached image from the database.
///
- ///
+ ///
/// The key for the cached image.
///
///
/// The true if the addition of the cached image is removed; otherwise, false.
///
- private static int RemoveImage(string key)
+ internal static async Task RemoveImageAsync(CachedImage cachedImage)
{
try
{
- int id = 0;
- SQLiteConnection connection = new SQLiteConnection(ConnectionString);
-
- id = connection.Delete(key);
- connection.Dispose();
+ SQLiteAsyncConnection connection = new SQLiteAsyncConnection(ConnectionString);
- return id;
+ return await connection.DeleteAsync(cachedImage);
}
catch
{