NamedCacheContains Method (Byte)

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.1.0.0
Syntax

public bool Contains(
	byte[] id
)

Parameters

id
Type: SystemByte
Object identifier (must be either 16 or 32 bytes in length).

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(Byte, 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(Byte, Object) or ItemByte, 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