﻿Cache(TKey, TValue).GetThreadSafeAccessor Method

CacheTKey, TValueGetThreadSafeAccessor Method

KGy SOFT Core Libraries Help
Gets a thread safe accessor for this CacheTKey, TValue instance. As it provides only a single readable indexer, it makes sense only if an item loader was passed to the appropriate constructor and the cache will not be accessed by other members but via the returned accessor.

Namespace:  KGySoft.Collections
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0

public IThreadSafeCacheAccessor<TKey, TValue> GetThreadSafeAccessor(
	bool protectItemLoader = false


protectItemLoader (Optional)
Type: SystemBoolean
 to ensure that also the item loader is locked if a new element has to be loaded and  to allow the item loader to be called concurrently. In latter case the CacheTKey, TValue is not locked during the time the item loader is being called but it can happen that values for same key are loaded multiple times and all but one will be discarded. This parameter is optional.
Default value: .

Return Value

Type: IThreadSafeCacheAccessorTKey, TValue
An IThreadSafeCacheAccessorTKey, TValue instance providing a thread-safe readable indexer for this CacheTKey, TValue instance.

See Also