Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Class ObjectInstanceCacheExtensions

Extension methods for EPiServer.Framework.Cache.IObjectInstanceCache

Inheritance
System.Object
ObjectInstanceCacheExtensions
Namespace: Mediachase.Commerce.Extensions
Assembly: Mediachase.Commerce.dll
Version: 14.26.0
Syntax
public static class ObjectInstanceCacheExtensions : Object

Methods

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.