Assembly: soss_namedcache (in soss_namedcache.dll) Version: 18.104.22.168
public bool Contains( CachedObjectId id )
Public Function Contains ( id As CachedObjectId ) As Boolean
- Type: Soss.ClientCachedObjectId
Return ValueType: Boolean
true if the object is in cache, otherwise false
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.