Open sandboxFocus

Method GetOrAdd

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.

Declaration
public object GetOrAdd(MethodInfo method, string key, Type valueType, CacheItemConfiguration configuration, Func<object> valueProvider, LogSource logger)
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.

CacheItemConfiguration configuration

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

Func<object> valueProvider

A delegate that evaluates the value.

LogSource logger

The LogSource of the declaring type of the cached method.

Returns
Type Description
object

The cached or evaluated value.

Implements