Open sandboxFocus

Class CacheConfigurationAttribute

Custom attribute that, when applied to a type, configures the CacheAttribute aspects applied to the methods of this type or its derived types. When applied to an assembly, the CacheConfigurationAttribute custom attribute configures all methods of the current assembly.

Inheritance
CacheConfigurationAttribute
Namespace: PostSharp.Patterns.Caching
Assembly: PostSharp.Patterns.Caching.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class)]
public sealed class CacheConfigurationAttribute : Attribute
Remarks

Any CacheConfigurationAttribute on the base class always has priority over a CacheConfigurationAttribute on the assembly, even if the base class is in a different assembly.

Configuration is resolved at build time, property by property. For each property, the first value found in the following order wins: the CacheAttribute itself, the CacheConfigurationAttribute on the declaring type, then on each base type from the nearest to the farthest, then on the assembly that declares the cached method, and finally the CachingProfile at run time. Assembly-level CacheConfigurationAttribute instances of other assemblies are ignored.

Constructors

Name Description
CacheConfigurationAttribute()

Properties

Name Description
AbsoluteExpiration

Gets or sets the total duration, in minutes, during which the result of the cached method is stored in the cache. The absolute expiration time is counted from the moment the method is evaluated and cached.

AutoReload

Gets or sets a value indicating whether the method calls are automatically reloaded (by re-evaluating the target method with the same arguments) when the cache item is removed from the cache.

IgnoreThisParameter

Gets or sets a value indicating whether the this instance should be a part of the cache key. The default value of this property is false, which means that by default the this instance is a part of the cache key.

Priority

Gets or sets the priority of the cached method.

ProfileName

Gets or sets the name of the CachingProfile that contains the configuration of the cached methods.

SlidingExpiration

Gets or sets the duration, in minutes, during which the result of the cached method is stored in the cache after it has been added to or accessed from the cache. The expiration is extended every time the value is accessed from the cache.

StaticMethodFallbackSeverity

Gets or sets the severity of the message reported when a static method uses DefaultService although UseDependencyInjection is true. The default value is Warning. Set it to Error to require that every cached method receives its service from the container, or to None to accept the fallback silently.

UseDependencyInjection

Gets or sets a value indicating whether the classes in scope receive their ICachingService from a dependency injection container. The default value is false, which means that the cached methods use DefaultService.

See Also