diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/CacheOptions.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/CacheOptions.cs
index 70f13c6b18..6be122be8f 100644
--- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/CacheOptions.cs
+++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/CacheOptions.cs
@@ -10,11 +10,13 @@ namespace Volo.Abp.Caching
/// Global Cache entry options.
///
public DistributedCacheEntryOptions GlobalCacheEntryOptions { get; set; }
+
///
/// List of all cache configurators.
/// (func argument:Name of cache)
///
public List> CacheConfigurators { get; set; } //TODO list item use a configurator interface instead?
+
public CacheOptions()
{
CacheConfigurators = new List>();
diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
index 9ec056d4d7..e4d2c70ba5 100644
--- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
+++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
@@ -12,6 +12,10 @@ using Volo.Abp.Threading;
namespace Volo.Abp.Caching
{
+ ///
+ /// Represents a distributed cache of type.
+ ///
+ /// The type of cache item being cached.
public class DistributedCache : IDistributedCache
where TCacheItem : class
{
@@ -57,6 +61,12 @@ namespace Volo.Abp.Caching
SetDefaultOptions();
}
+ ///
+ /// Gets a cache item with the given key. If no cache item is found for the given key then returns null.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The cache item, or null.
public virtual TCacheItem Get(
string key,
bool? hideErrors = null)
@@ -88,6 +98,13 @@ namespace Volo.Abp.Caching
return Serializer.Deserialize(cachedBytes);
}
+ ///
+ /// Gets a cache item with the given key. If no cache item is found for the given key then returns null.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The cache item, or null.
public virtual async Task GetAsync(
string key,
bool? hideErrors = null,
@@ -123,6 +140,15 @@ namespace Volo.Abp.Caching
return Serializer.Deserialize(cachedBytes);
}
+ ///
+ /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item
+ /// provided by delegate and returns the provided cache item.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The factory delegate is used to provide the cache item when no cache item is found for the given .
+ /// The cache options for the factory delegate.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The cache item.
public TCacheItem GetOrAdd(
string key,
Func factory,
@@ -150,6 +176,16 @@ namespace Volo.Abp.Caching
return value;
}
+ ///
+ /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item
+ /// provided by delegate and returns the provided cache item.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The factory delegate is used to provide the cache item when no cache item is found for the given .
+ /// The cache options for the factory delegate.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The cache item.
public async Task GetOrAddAsync(
string key,
Func> factory,
@@ -179,6 +215,13 @@ namespace Volo.Abp.Caching
return value;
}
+ ///
+ /// Sets the cache item value for the provided key.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The cache item value to set in the cache.
+ /// The cache options for the value.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
public virtual void Set(
string key,
TCacheItem value,
@@ -207,6 +250,15 @@ namespace Volo.Abp.Caching
}
}
+ ///
+ /// Sets the cache item value for the provided key.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The cache item value to set in the cache.
+ /// The cache options for the value.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
public virtual async Task SetAsync(
string key,
TCacheItem value,
@@ -237,6 +289,11 @@ namespace Volo.Abp.Caching
}
}
+ ///
+ /// Refreshes the cache value of the given key, and resets its sliding expiration timeout.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
public virtual void Refresh(
string key,
bool? hideErrors = null)
@@ -259,6 +316,13 @@ namespace Volo.Abp.Caching
}
}
+ ///
+ /// Refreshes the cache value of the given key, and resets its sliding expiration timeout.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
public virtual async Task RefreshAsync(
string key,
bool? hideErrors = null,
@@ -282,6 +346,12 @@ namespace Volo.Abp.Caching
}
}
+
+ ///
+ /// Removes the cache item for given key from cache.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
public virtual void Remove(
string key,
bool? hideErrors = null)
@@ -303,6 +373,13 @@ namespace Volo.Abp.Caching
}
}
+ ///
+ /// Removes the cache item for given key from cache.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
public virtual async Task RemoveAsync(
string key,
bool? hideErrors = null,
diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs
index 1567bfca30..23bd6f4cf2 100644
--- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs
+++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs
@@ -6,20 +6,46 @@ using Microsoft.Extensions.Caching.Distributed;
namespace Volo.Abp.Caching
{
+ ///
+ /// Represents a distributed cache of type.
+ ///
+ /// The type of cache item being cached.
public interface IDistributedCache
where TCacheItem : class
{
+ ///
+ /// Gets a cache item with the given key. If no cache item is found for the given key then returns null.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The cache item, or null.
TCacheItem Get(
string key,
bool? hideErrors = null
);
+ ///
+ /// Gets a cache item with the given key. If no cache item is found for the given key then returns null.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The cache item, or null.
Task GetAsync(
[NotNull] string key,
bool? hideErrors = null,
CancellationToken token = default
);
+ ///
+ /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item
+ /// provided by delegate and returns the provided cache item.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The factory delegate is used to provide the cache item when no cache item is found for the given .
+ /// The cache options for the factory delegate.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The cache item.
TCacheItem GetOrAdd(
string key,
Func factory,
@@ -27,6 +53,16 @@ namespace Volo.Abp.Caching
bool? hideErrors = null
);
+ ///
+ /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item
+ /// provided by delegate and returns the provided cache item.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The factory delegate is used to provide the cache item when no cache item is found for the given .
+ /// The cache options for the factory delegate.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The cache item.
Task GetOrAddAsync(
[NotNull] string key,
Func> factory,
@@ -35,6 +71,13 @@ namespace Volo.Abp.Caching
CancellationToken token = default
);
+ ///
+ /// Sets the cache item value for the provided key.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The cache item value to set in the cache.
+ /// The cache options for the value.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
void Set(
string key,
TCacheItem value,
@@ -42,6 +85,15 @@ namespace Volo.Abp.Caching
bool? hideErrors = null
);
+ ///
+ /// Sets the cache item value for the provided key.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// The cache item value to set in the cache.
+ /// The cache options for the value.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
Task SetAsync(
[NotNull] string key,
[NotNull] TCacheItem value,
@@ -50,22 +102,46 @@ namespace Volo.Abp.Caching
CancellationToken token = default
);
+ ///
+ /// Refreshes the cache value of the given key, and resets its sliding expiration timeout.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
void Refresh(
string key,
bool? hideErrors = null
);
+ ///
+ /// Refreshes the cache value of the given key, and resets its sliding expiration timeout.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
Task RefreshAsync(
string key,
bool? hideErrors = null,
CancellationToken token = default
);
+ ///
+ /// Removes the cache item for given key from cache.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
void Remove(
string key,
bool? hideErrors = null
);
+ ///
+ /// Removes the cache item for given key from cache.
+ ///
+ /// The key of cached item to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
Task RemoveAsync(
string key,
bool? hideErrors = null,