Open sandboxFocus

Interface ICacheDependency

Interface that must be implemented by classes that need to be used as cache dependencies, for use with the AddDependency(ICacheDependency) method. Alternatively, custom classes may implement the IFormattable interface or simply the ToString() method.

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

Implementing this interface encapsulates the generation of the dependency key in the dependency object, so that the cached method and the invalidating method cannot build different keys. Add the dependency from the cached method by calling AddDependency(ICacheDependency) on CurrentContext, and invalidate it by calling Invalidate(ICacheDependency). The string returned by GetCacheKey() is used as the dependency key as is.

When you cannot modify the dependency class, register a formatter for it instead.

Methods

Name Description
GetCacheKey()

Gets a string that uniquely represents the current object.

See Also