Open sandboxFocus

Method GetFromCacheOrExecuteValueTaskAsync

GetFromCacheOrExecuteValueTaskAsync<TTaskResultType>(CachedMethodMetadata, object?, object?[], Func<object?, object?[], CancellationToken, ValueTask<object?>>, CacheItemConfiguration?, CancellationToken)

Gets a value from the cache or executes an asynchronous method returning ValueTask<TResult> and caches the result. This method is called by the generated code of the CacheAttribute aspect.

Declaration
public ValueTask<TTaskResultType?> GetFromCacheOrExecuteValueTaskAsync<TTaskResultType>(CachedMethodMetadata metadata, object? instance, object?[] args, Func<object?, object?[], CancellationToken, ValueTask<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 null for static methods.

object[] args

The method arguments.

Func<object, object[], CancellationToken, ValueTask<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
ValueTask<TTaskResultType>

A value task representing the cached or computed result.

Type Parameters
Name Description
TTaskResultType

The type of the value task result.

Implements