Table of Contents

GetOrAdd Method

Definition

Namespace
Cuemon.Extensions.Runtime.Caching
Assemblies
Cuemon.Extensions.Runtime.Caching.dll
Source
src/Cuemon.Extensions.Runtime.Caching/CacheEnumerableExtensions.cs

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, IDependency, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, IDependency dependency, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

dependency IDependency

An IDependency implementations that monitors changes in the state of the data which a cache entry depends on. If a state change is registered, the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, string, IDependency, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, string ns, IDependency dependency, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

ns string

The optional namespace that provides a scope to the cache. Default is NoScope.

dependency IDependency

An IDependency implementations that monitors changes in the state of the data which a cache entry depends on. If a state change is registered, the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, IEnumerable<IDependency>, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, IEnumerable<IDependency> dependencies, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

dependencies IEnumerable<IDependency>

A sequence of IDependency implementations that monitors changes in the state of the data which a cache entry depends on. If a state change is registered, the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, string, IEnumerable<IDependency>, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, string ns, IEnumerable<IDependency> dependencies, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

ns string

The optional namespace that provides a scope to the cache. Default is NoScope.

dependencies IEnumerable<IDependency>

A sequence of IDependency implementations that monitors changes in the state of the data which a cache entry depends on. If a state change is registered, the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, TimeSpan, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, TimeSpan slidingExpiration, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

slidingExpiration TimeSpan

The sliding expiration time from when the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, string, TimeSpan, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, string ns, TimeSpan slidingExpiration, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

ns string

The optional namespace that provides a scope to the cache. Default is NoScope.

slidingExpiration TimeSpan

The sliding expiration time from when the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, DateTime, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, DateTime absoluteExpiration, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

absoluteExpiration DateTime

The absolute expiration date time value from when the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, string, DateTime, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, string ns, DateTime absoluteExpiration, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

ns string

The optional namespace that provides a scope to the cache. Default is NoScope.

absoluteExpiration DateTime

The absolute expiration date time value from when the cached entry becomes invalid and is removed from the cache.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, CacheInvalidation, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, CacheInvalidation invalidation, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

invalidation CacheInvalidation

The object that contains expiration details for a specific cache entry.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.

GetOrAdd<TKey, TResult>(ICacheEnumerable<TKey>, string, string, CacheInvalidation, Func<TResult>)

Gets the value for the specified key from the cache, or if the key does not exists, adds a value to the cache using the specified function delegate valueFactory.

public static TResult GetOrAdd<TKey, TResult>(this ICacheEnumerable<TKey> cache, string key, string ns, CacheInvalidation invalidation, Func<TResult> valueFactory)

Parameters

cache ICacheEnumerable<TKey>

The ICacheEnumerable<TKey> to extend.

key string

The unique identifier for the cache entry.

ns string

The optional namespace that provides a scope to the cache. Default is NoScope.

invalidation CacheInvalidation

The object that contains expiration details for a specific cache entry.

valueFactory Func<TResult>

The function delegate used to provide a value for the key.

Returns

TResult

The value for the specified key. This will either be the existing value if the key is already in the cache, or the new value returned by valueFactory if the key was not in the cache.

Type Parameters

TKey

The type of the key in the cache.

TResult

The type of the value in the cache.