Open sandboxFocus

Interface ICachingContext

Represents the context in which a method being cached is executing.

Namespace: PostSharp.Patterns.Caching
Assembly: PostSharp.Patterns.Caching.dll
Syntax
public interface ICachingContext
Remarks

Get the current context from CurrentContext. Dependencies added to it while a cached method is being evaluated are attached to the cached result, which is removed from the cache when one of its dependencies is invalidated through CachingServices.Invalidation. Outside of a cached method, the current context ignores the dependencies added to it.

The context flows to the methods called by the cached method. When the backend supports dependencies, a cached method called by another cached method becomes a dependency of the caller, even when its result comes from the cache. To prevent this propagation, for example for a task that the cached method starts and does not wait for, use SuspendDependencyPropagation().

Properties

Name Description
Kind

Gets the kind of ICachingContext.

Parent

Gets the parent context.

Methods

Name Description
AddDependencies(IEnumerable<ICacheDependency>)

Adds a set of dependencies represented as ICacheDependency to the current context.

AddDependencies(IEnumerable<string>)

Adds a set of dependencies represented as keys to the current context.

AddDependency(ICacheDependency)

Adds a dependency represented as an ICacheDependency to the current context.

AddDependency(object)

Adds a dependency object to the current context. Calling this method is equivalent to wrapping the object into an ObjectDependency and calling the AddDependency(ICacheDependency) overload.

AddDependency(string)

Adds a dependency represented as a key to the current context.

See Also