ThreadSafeCacheFactoryCreateTKey, TValue(FuncTKey, TValue, ThreadSafeCacheOptionsBase) Method

Creates a thread safe cache instance that can be accessed as an IThreadSafeCacheAccessorTKey, TValue instance.
See the Remarks section of the CreateTKey, TValue(FuncTKey, TValue, IEqualityComparerTKey, ThreadSafeCacheOptionsBase) overload for details.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public static IThreadSafeCacheAccessor<TKey, TValue> Create<TKey, TValue>(
	Func<TKey, TValue> itemLoader,
	ThreadSafeCacheOptionsBase? options = null
)

Parameters

itemLoader  FuncTKey, TValue
A delegate for loading a value, which is invoked when a key is not present in the cache.
options  ThreadSafeCacheOptionsBase  (Optional)
The options for creating the cache. If , then a default LockFreeCacheOptions instance will be used. This parameter is optional.
Default value: .

Type Parameters

TKey
The type of the key in the cache.
TValue
The type of the value in the cache.

Return Value

IThreadSafeCacheAccessorTKey, TValue
An IThreadSafeCacheAccessorTKey, TValue instance that can be used to read the underlying cache in a thread-safe manner.

See Also