Try our conversational search powered by Generative AI!

Class ObjectInstanceCacheExtensions

Extension methods for EPiServer.Framework.Cache.IObjectInstanceCache

Inheritance
System.Object
ObjectInstanceCacheExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Mediachase.Commerce.Extensions
Assembly: Mediachase.Commerce.dll
Version: 13.30.0
Syntax
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 cache is not of type EPiServer.Framework.Cache.HttpRuntimeCache

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 true use the cache, otherwise bypass.

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.