Open sandboxFocus

Class CacheAttribute

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.

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

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.

Constructors

Name Description
CacheAttribute()

Methods

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