MetalamaAPI documentationPatterns APIMetalama.​Patterns.​Caching.​AspectsCache­Attribute
Open sandboxFocus

CacheAttribute Class

Custom attribute that, when applied on a method, causes the return value of the method to be cached for the specific list of arguments passed to this method call.

Namespace: Metalama.Patterns.Caching.Aspects
Assembly: Metalama.Patterns.Caching.Aspects.dll
public sealed class CacheAttribute : CachingBaseAttribute, IHierarchicalOptionsProvider, IAspect<IMethod>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<IMethod>

There are several ways to configure the behavior of the CacheAttribute aspect: you can set the properties of the CacheAttribute class, such as AbsoluteExpiration or SlidingExpiration. You can add the CachingConfigurationAttribute custom attribute to the declaring type, a base type, or the declaring assembly. Finally, you can define a profile by setting the ProfileName property and configure the profile at run time by accessing the Profiles collection of the ICachingService class.

Use the NotCacheKeyAttribute custom attribute to exclude a parameter from being a part of the cache key.

To invalidate a cached method, see InvalidateCacheAttribute and the Invalidate<TReturn, TParam1>(ICachingService, Func<TParam1, TReturn>, TParam1) method.


Name Description


Name Description
OverrideMethod<TReturnType>(IField, IType, IField)
OverrideMethodAsyncEnumerable<TValue>(IField, IType, IField)
OverrideMethodAsyncEnumerator<TValue>(IField, IType, IField)
OverrideMethodAsyncTask<TValue>(IField, IType, IField)
OverrideMethodAsyncValueTask<TValue>(IField, IType, IField)

Explicit Interface Implementations

Name Description