Try our conversational search powered by Generative AI!

Class CacheEvictionPolicy

Contains the different cache evicion policies that can be assigned for an item in IObjectInstanceCache.

Inheritance
System.Object
CacheEvictionPolicy
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.Framework.Cache
Assembly: EPiServer.Framework.dll
Version: 11.20.7
Syntax
public class CacheEvictionPolicy
Remarks

Once an instance of CacheEvictionPolicy has been created, the instance is immutable. This is done to allow for re-using the same CacheEvictionPolicy instance multiple times when you have identical cache policy requirements for multiple cache insertions.

Constructors

CacheEvictionPolicy(IEnumerable<String>)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
public CacheEvictionPolicy(IEnumerable<string> cacheKeys)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

CacheEvictionPolicy(IEnumerable<String>, IEnumerable<String>)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
public CacheEvictionPolicy(IEnumerable<string> cacheKeys, IEnumerable<string> masterKeys)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.Collections.Generic.IEnumerable<System.String> masterKeys

The master keys that we depend upon.

CacheEvictionPolicy(IEnumerable<String>, IEnumerable<String>, IEnumerable<String>)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
[Obsolete("Use another constructor")]
public CacheEvictionPolicy(IEnumerable<string> files, IEnumerable<string> cacheKeys, IEnumerable<string> masterKeys)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> files

The files that the item depends upon.

System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.Collections.Generic.IEnumerable<System.String> masterKeys

The master keys that we depend upon.

CacheEvictionPolicy(IEnumerable<String>, IEnumerable<String>, IEnumerable<String>, TimeSpan, CacheTimeoutType)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
[Obsolete("Use another constructor")]
public CacheEvictionPolicy(IEnumerable<string> files, IEnumerable<string> cacheKeys, IEnumerable<string> masterKeys, TimeSpan expiration, CacheTimeoutType timeoutType)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> files

The files that the item depends upon.

System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.Collections.Generic.IEnumerable<System.String> masterKeys

The master keys that we depend upon.

System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

CacheEvictionPolicy(IEnumerable<String>, IEnumerable<String>, TimeSpan, CacheTimeoutType)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
[Obsolete("Use another constructor")]
public CacheEvictionPolicy(IEnumerable<string> files, IEnumerable<string> cacheKeys, TimeSpan expiration, CacheTimeoutType timeoutType)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> files

The files that the item depends upon.

System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

CacheEvictionPolicy(IEnumerable<String>, TimeSpan, CacheTimeoutType)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
[Obsolete("Use another constructor")]
public CacheEvictionPolicy(IEnumerable<string> cacheKeys, TimeSpan expiration, CacheTimeoutType timeoutType)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

CacheEvictionPolicy(TimeSpan, CacheTimeoutType)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
public CacheEvictionPolicy(TimeSpan expiration, CacheTimeoutType timeoutType)
Parameters
Type Name Description
System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

CacheEvictionPolicy(TimeSpan, CacheTimeoutType, IEnumerable<String>)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
public CacheEvictionPolicy(TimeSpan expiration, CacheTimeoutType timeoutType, IEnumerable<string> cacheKeys)
Parameters
Type Name Description
System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

CacheEvictionPolicy(TimeSpan, CacheTimeoutType, IEnumerable<String>, IEnumerable<String>)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
public CacheEvictionPolicy(TimeSpan expiration, CacheTimeoutType timeoutType, IEnumerable<string> cacheKeys, IEnumerable<string> masterKeys)
Parameters
Type Name Description
System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.Collections.Generic.IEnumerable<System.String> masterKeys

The master keys that we depend upon.

CacheEvictionPolicy(TimeSpan, CacheTimeoutType, IEnumerable<String>, IEnumerable<String>, IEnumerable<String>)

Initializes a new instance of the CacheEvictionPolicy class.

Declaration
[Obsolete("Use another constructor")]
public CacheEvictionPolicy(TimeSpan expiration, CacheTimeoutType timeoutType, IEnumerable<string> cacheKeys, IEnumerable<string> masterKeys, IEnumerable<string> files)
Parameters
Type Name Description
System.TimeSpan expiration

The expiration time span.

CacheTimeoutType timeoutType

Type of cache timeout.

System.Collections.Generic.IEnumerable<System.String> cacheKeys

The dependencies to other cached items, idetified by their keys.

System.Collections.Generic.IEnumerable<System.String> masterKeys

The master keys that we depend upon.

System.Collections.Generic.IEnumerable<System.String> files

The files that the item depends upon.

Fields

Empty

The empty CacheEvictionPolicy.

Declaration
public static readonly CacheEvictionPolicy Empty
Field Value
Type Description
CacheEvictionPolicy
Remarks

No special expiration policies have been defined.

Properties

CacheKeys

Gets the cache dependency keys.

Declaration
public string[] CacheKeys { get; }
Property Value
Type Description
System.String[]

The cache keys.

Remarks

If a dependent cache item with one of the specified cachekeys does not exist in cache then the inserted item will be evicted from cache immediately.

Expiration

Gets the expiration time span.

Declaration
public TimeSpan Expiration { get; }
Property Value
Type Description
System.TimeSpan

The expiration.

Remarks

If TimeoutType is set to Absolute, this is how long the item will remain in the cache before it is considered invalid. If TimeoutType is set to Sliding, then this is how long the item will be considered valid after the latest access. If TimeoutType is set to Undefined, this value is ignored.

Files

Gets the file dependencies.

Declaration
[Obsolete("No longer supported, use own FileSystemWatcher and invalidate cache items if needed")]
public string[] Files { get; }
Property Value
Type Description
System.String[]

The files.

Remarks

The strings should be fully qualified local file system paths to the dependent files.

MasterKeys

Gets the master keys.

Declaration
public string[] MasterKeys { get; }
Property Value
Type Description
System.String[]

The master keys.

Remarks

Master keys are used as markers to set up common dependencies without having to create the cache entries first. If you set up a master key dependency, there is no need for the corresponding entry to exist before adding something that depends on the master key.

The concept of master keys could be regarded as similar to the cache region concept, but using master keys allows you to have more than one, where cache regions is restricted to one per cached item - you can only place the item in one region.

TimeoutType

Gets the type of cache timeout.

Declaration
public CacheTimeoutType TimeoutType { get; }
Property Value
Type Description
CacheTimeoutType

The type of the timeout.

Remarks

See Expiration for more information.

Extension Methods