MemoryCacheTGetOrAdd(String, FuncT, CacheEntryRemovedCallback) Method

Gets or adds a value, based on result of valueFactory, to the memory cache. Cache defaults to a 1-minute expiration.

Definition

Namespace: Gemstone.Caching
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.169 -- Release Build+7345f63a8c9771f20dc280b192df2ccb62049660
public static T GetOrAdd(
	string cacheName,
	Func<T> valueFactory,
	CacheEntryRemovedCallback? removedCallBack = null
)

Parameters

cacheName  String
Name to use as cache key -- this should be unique per T.
valueFactory  FuncT
Function to generate value to add to cache -- only called if value is not already cached.
removedCallBack  CacheEntryRemovedCallback  (Optional)
Optional function to call when cache entry is removed.

Return Value

T
Value from cache if already cached; otherwise, new value generated by valueFactory.

See Also