Default implementation of ICacheKeyBuilder that builds cache item keys and dependency keys.
Namespace: Metalama.Patterns.Caching.Formatters
Assembly: Metalama.Patterns.Caching.dll
Syntax
public class CacheKeyBuilder : IDisposable, ICacheKeyBuilderRemarks
This class generates cache keys by combining method signature information with formatted argument values. The format includes the declaring type, method name, generic arguments, and parameter values.
To customize key generation, either derive from this class and override the virtual methods, or implement ICacheKeyBuilder directly. Register custom implementations using WithKeyBuilder(Func<IFormatterRepository, CacheKeyBuilderOptions, ICacheKeyBuilder>).
Constructors
| Name | Description |
|---|---|
| CacheKeyBuilder(IFormatterRepository, CacheKeyBuilderOptions) | Initializes a new instance of the CacheKeyBuilder class specifying the maximal key size and optionally a IFormatterRepository. |
Properties
| Name | Description |
|---|---|
| Formatters | Gets the formatters used to build the caching key. |
| IgnoredParameterSentinel | Gets a sentinel object that means that the parameter is not a part of the cache key, and should be ignored. |
| MaxKeySize | Gets the maximal number of characters in cache keys. |
Methods
| Name | Description |
|---|---|
| AppendArgument(UnsafeStringBuilder, Type, object?) | Appends a method argument to an UnsafeStringBuilder. To avoid ambiguities between different overloads of the same method, the default implementation appends both the parameter type and the value key. |
| AppendMethod(UnsafeStringBuilder, MethodInfo) | Appends the method name and generic arguments to an UnsafeStringBuilder. |
| AppendObject(UnsafeStringBuilder, object) | Appends a string representing an object to an UnsafeStringBuilder. |
| AppendType(UnsafeStringBuilder, Type) | Appends a Type name to an UnsafeStringBuilder. |
| BuildDependencyKey(object) | Builds a dependency key for a given object. |
| BuildMethodKey(CachedMethodMetadata, object?, IList<object?>) | Builds a cache key for a given method call. |
| Dispose() | |
| Dispose(bool) | Disposes the current object. |