The default implementation of ICachingService: a cache made of a backend, a key builder and caching profiles. Register an instance as a singleton in a dependency injection container, or configure DefaultService.
Implements
Namespace: PostSharp.Patterns.Caching
Assembly: PostSharp.Patterns.Caching.dll
Syntax
public sealed class CachingService : ICachingServiceConstructors
| Name | Description |
|---|---|
| CachingService() | Initializes a new instance of the CachingService class without a backend. Set the Backend property before the first call to a cached method; until it is set, calling a cached method throws a CachingException. |
| CachingService(CachingBackend, CacheKeyBuilder) | Initializes a new instance of the CachingService class. |
Properties
| Name | Description |
|---|---|
| Backend | Gets or sets the backend that stores the cached items. Setting this property to |
| KeyBuilder | Gets or sets the key builder that computes the keys of the cached items. Setting this property to |
| Profiles | Gets the caching profiles (CachingProfile) of the methods cached by this service. |
Methods
| Name | Description |
|---|---|
| GetOrAdd(MethodInfo, string, Type, CacheItemConfiguration, Func<object>, LogSource) | Gets a value from the cache or, when the cache has no item for the key, evaluates the value, adds it to the cache and returns it. The CacheAttribute aspect calls this method. |
| GetOrAddAsync(MethodInfo, string, Type, CacheItemConfiguration, Func<Task<object>>, LogSource, CancellationToken) | Asynchronously gets a value from the cache or, when the cache has no item for the key, evaluates the value, adds it to the cache and returns it. The CacheAttribute aspect calls this method for asynchronous methods. |
| Invalidate(ICacheDependency) | Invalidates a cache dependency given as an ICacheDependency, i.e. removes all cache items that are dependent on this dependency. |
| Invalidate(object) | Invalidates a cache dependency given an object, i.e. removes all cached items that are dependent on that object. |
| Invalidate(MethodInfo, object, params object[]) | Removes a method call result from the cache, using the MethodInfo that represents the method, the instance and the arguments of the method call. The InvalidateCacheAttribute aspect calls this method. |
| Invalidate(string) | Invalidates a cache dependency given as string, i.e. removes all cache items that are dependent on this dependency key. |
| InvalidateAsync(ICacheDependency) | Asynchronously invalidates a cache dependency given as an ICacheDependency, i.e. removes all cache items that are dependent on this dependency. |
| InvalidateAsync(object) | Asynchronously invalidates a cache dependency given an object, i.e. removes all cached items that are dependent on that object. |
| InvalidateAsync(MethodInfo, object, params object[]) | Asynchronously removes a method call result from the cache, using the MethodInfo that represents the method, the instance and the arguments of the method call. The InvalidateCacheAttribute aspect calls this method for asynchronous methods. |
| InvalidateAsync(string) | Asynchronously invalidates a cache dependency given as string, i.e. removes all cache items that are dependent on this dependency key. |