Allows for centralized and run-time configuration of several instances of the CacheAttribute aspect.
Implements
Namespace: PostSharp.Patterns.Caching
Assembly: PostSharp.Patterns.Caching.dll
Syntax
public sealed class CachingProfile : ICacheItemConfigurationRemarks
Profiles are exposed by name on the Profiles collection, which creates a profile the first time its name is requested. Cached methods select a profile with the ProfileName or ProfileName property, and use the default profile (Default) when they specify none.
A profile setting applies only to the properties that are not set by the CacheAttribute or by a CacheConfigurationAttribute.
Unlike these custom attributes, a profile can be changed at run time, for example to disable caching with the IsEnabled property.
Whether the this instance is part of the cache key cannot be set in a profile because it is resolved at build time.
Locking is configured only on profiles, with the LockManager, AcquireLockTimeout and AcquireLockTimeoutStrategy properties.
Constructors
| Name | Description |
|---|---|
| CachingProfile(string) | Initializes a new instance of the CachingProfile class. |
Fields
| Name | Description |
|---|---|
| DefaultName | The name of the default profile. |
Properties
| Name | Description |
|---|---|
| AbsoluteExpiration | Gets or sets the total duration during which the result of the current method is stored in the cache. The absolute expiration time is counted from the moment the method is evaluated and cached. |
| AcquireLockTimeout | Gets or sets the maximum time that the caching aspect will wait for the LockManager to acquire a lock.
To specify an infinite waiting time, set this property to |
| AcquireLockTimeoutStrategy | Gets or sets the behavior when the caching aspect cannot acquire a lock because of a timeout. The default behavior is to throw a TimeoutException. You can implement your own strategy by implementing the IAcquireLockTimeoutStrategy interface. If the OnTimeout(string) does not return any exception, the cached method will be evaluated (even without a lock). |
| 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. |
| IsEnabled | Gets or sets a value indicating whether caching is enabled for the current profile. |
| LockManager | Gets or sets the lock manager used to synchronize the execution of methods that are cached with the current profile. The default lock manager is NullLockManager, which allows for concurrent execution of all methods. An alternative implementation is LocalLockManager, which prevents concurrent execution of the same method with the same parameters, in the current process (or AppDomain). |
| Name | Gets the name of the profile. The comparison is case-insensitive. |
| Priority | Gets or sets the priority of the cached methods. |
| SlidingExpiration | Gets or sets the duration during which the result of the current 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. |