Open sandboxFocus

Method GetOrAddAsync

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.

Declaration
public Task<object> GetOrAddAsync(MethodInfo method, string key, Type valueType, CacheItemConfiguration configuration, Func<Task<object>> valueProvider, LogSource logger, CancellationToken cancellationToken)
Parameters
Type Name Description
MethodInfo method

The cached method.

string key

The cache key, computed by KeyBuilder.

Type valueType

The type of the cached value, i.e. the type of the result of the task.

CacheItemConfiguration configuration

The configuration of the cached method, already merged with its profile.

Func<Task<object>> valueProvider

A delegate that evaluates the value.

LogSource logger

The LogSource of the declaring type of the cached method.

CancellationToken cancellationToken

A CancellationToken.

Returns
Type Description
Task<object>

A Task<TResult> that evaluates to the cached or evaluated value.

Implements