Class ObjectInstanceCacheExtensions
Extension methods for EPiServer.Framework.Cache.IObjectInstanceCache
Inheritance
Inherited Members
Namespace: Mediachase.Commerce.Extensions
Assembly: Mediachase.Commerce.dll
Version: 12.17.2Syntax
public static class ObjectInstanceCacheExtensions
Methods
AssertCompatibleCacheImplementation(IObjectInstanceCache)
Asserts if the supplied cache implementation is of type EPiServer.Framework.Cache.HttpRuntimeCache, otherwise throws an excepttion.
Declaration
public static void AssertCompatibleCacheImplementation(this IObjectInstanceCache cache)
Parameters
Type | Name | Description |
---|---|---|
EPiServer.Framework.Cache.IObjectInstanceCache | cache | The cache. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if |
ReadThrough<T>(IObjectInstanceCache, Boolean, String, IEnumerable<String>, TimeSpan, Func<T>)
Gets an item from cache, and if there is a cache miss, gets the item using the supplied delegate and caches the result.
Declaration
public static T ReadThrough<T>(this IObjectInstanceCache cache, bool useCache, string cacheKey, IEnumerable<string> masterKeys, TimeSpan duration, Func<T> load)
where T : class
Parameters
Type | Name | Description |
---|---|---|
EPiServer.Framework.Cache.IObjectInstanceCache | cache | The cache implementation to use. |
System.Boolean | useCache | if set to |
System.String | cacheKey | The cache key for the item. |
System.Collections.Generic.IEnumerable<System.String> | masterKeys | The master keys the cached item should depend on. |
System.TimeSpan | duration | The cache duration. |
System.Func<T> | load | The delegate to execute to get the item if it is not in cache. |
Returns
Type | Description |
---|---|
T | The item from cache or as returned by the delegate if not in cache. |
Type Parameters
Name | Description |
---|---|
T | The type of item. |
ReadThrough<T>(IObjectInstanceCache, String, IEnumerable<String>, TimeSpan, Func<T>)
Gets an item from cache, and if there is a cache miss, gets the item using the supplied delegate and caches the result.
Declaration
public static T ReadThrough<T>(this IObjectInstanceCache cache, string cacheKey, IEnumerable<string> masterKeys, TimeSpan duration, Func<T> load)
where T : class
Parameters
Type | Name | Description |
---|---|---|
EPiServer.Framework.Cache.IObjectInstanceCache | cache | The cache implementation to use. |
System.String | cacheKey | The cache key for the item. |
System.Collections.Generic.IEnumerable<System.String> | masterKeys | The master keys the cached item should depend on. |
System.TimeSpan | duration | The cache duration. |
System.Func<T> | load | The delegate to execute to get the item if it is not in cache. |
Returns
Type | Description |
---|---|
T | The item from cache or as returned by the delegate if not in cache. |
Type Parameters
Name | Description |
---|---|
T | The type of item. |