NamedCacheContains Method (CachedObjectId)

ScaleOut Software NamedCache API
Checks if the cache contains an object with the given ID.

Namespace:  Soss.Client
Assembly:  soss_namedcache (in soss_namedcache.dll) Version: 6.2.0.0
Syntax

public bool Contains(
	CachedObjectId id
)

Parameters

id
Type: Soss.ClientCachedObjectId
Object identifier.

Return Value

Type: Boolean
true if the object is in cache, otherwise false
Remarks

The result of the Contains method is only accurate at the moment of the method's invocation; other clients may add or remove the object from the cache in the instant between the call to Contains and any subsequent code. As such, the Contains method is not well-suited for applications which require distributed synchronization and should only be used in a single-client scenario.

A safer, more reliable approach to distributed synchronization is to first attempt a retrieval of the cached object through a call to Retrieve(CachedObjectId, Boolean), which returns the object's data and optionally locks the object for exclusive use by the client. If the object does not exist then it can be added to the cache by using Add(CachedObjectId, Object) or ItemCachedObjectId, which are safe to use with other clients that may be trying to add the object at the same instant. See the example in the NamedCache overview for an illustration of this pattern.

See Also

Reference