MemoryCacheTGetOrAdd(String, Double, FuncT, CacheEntryRemovedCallback) Method

Gets or adds a value, based on result of valueFactory, to the memory cache.

Definition

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

Parameters

cacheName  String
Name to use as cache key -- this should be unique per T.
expirationTime  Double
Expiration time, in minutes, for cached value.
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