GetFromCacheOrExecute<TResult>(CachedMethodMetadata, object?, object?[], Func<object?, object?[], object?>, CacheItemConfiguration?, CancellationToken)
Gets a value from the cache or executes a synchronous method and caches the result.
This method is called by the generated code of the CacheAttribute aspect.
Declaration
TResult? GetFromCacheOrExecute<TResult>(CachedMethodMetadata metadata, object? instance, object?[] args, Func<object?, object?[], object?> func, CacheItemConfiguration? configuration = null, CancellationToken cancellationToken = default)Parameters
| Type | Name | Description |
|---|---|---|
| CachedMethodMetadata | metadata | Metadata about the cached method. |
| object | instance | The instance on which the method is called, or |
| object[] | args | The method arguments. |
| Func<object, object[], object> | func | A delegate that invokes the original method if the value is not in cache. |
| CacheItemConfiguration | configuration | Optional configuration overriding the default settings. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| TResult | The cached or computed result. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the cached value. |