DataCacheGetAndLock Method (String, DataCacheLockHandle)Windows Server AppFabric Caching Compatibility Library
Locks the cached object to prevent other clients from updating or removing it and returns the object corresponding to the key.

Namespace: Soss.Compat.WSAF
Assembly: soss_wsaf_compat (in soss_wsaf_compat.dll) Version: 1.1.0.100 (1.1.0.100)
Syntax

public Object GetAndLock(
	string key,
	out DataCacheLockHandle lockHandle
)

Parameters

key
Type: SystemString
The unique identifier used to access the object in the cache.
lockHandle
Type: Soss.Compat.WSAFDataCacheLockHandle
The DataCacheLockHandle object required to unlock the object (output parameter).

Return Value

Type: Object
The object in the cache that was stored in the cache with the specified key.

If the key does not exist, a DataCacheException is thrown with the ErrorCode set to KeyDoesNotExist.

If the object is already locked by another client, a DataCacheException is thrown with the ErrorCode set to ObjectLocked.

Remarks

Other clients calling GetAndLock on the same object while it is locked will fail as long as the lock remains valid. ScaleOut StateServer does not lock object for all client accesses - it allows the clients that do not use locking to get or update objects, but it prevents the object from being updated from the clients that use locking explicitly for their operations with objects. If the lock is not explicitly released by the client that originally obtained the lock, the object lock will automatically expire after 90 seconds (this lock expiration interval is configurable in the ScaleOut StateServer service).
See Also

Reference