Try our conversational search powered by Generative AI!

Class OptimisticCache<TObject>

A generic optimistic cache implementation.

Inheritance
System.Object
OptimisticCache<TObject>
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: EPiServer.Core
Assembly: EPiServer.dll
Version: 7.19.2
Syntax
public class OptimisticCache<TObject>

    where TObject : class
Type Parameters
Name Description
TObject

The type of the object to store in the cache.

Constructors

OptimisticCache()

Initializes a new instance of the OptimisticCache<TObject> class.

Declaration
public OptimisticCache()

Methods

Read(String, ReadAndCacheObject<TObject>)

Reads object from the cache based on the specified cache key.

Declaration
public static TObject Read(string cacheKey, ReadAndCacheObject<TObject> readAndCacheObject)
Parameters
Type Name Description
System.String cacheKey

The cache key.

ReadAndCacheObject<TObject> readAndCacheObject

The "read and cache object" implementation to call if the object was not found in the cache.

Returns
Type Description
TObject

The requested object.

TryRead(String, out TObject)

Tries to read an object from the cache.

Declaration
public static bool TryRead(string cacheKey, out TObject item)
Parameters
Type Name Description
System.String cacheKey

The cache key.

TObject item

The item from the cache.

Returns
Type Description
System.Boolean

True if the item was in the cache, false otherwise.

Extension Methods