DataCache.GetAndLock Method (String, TimeSpan, out DataCacheLockHandle, String)

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Returns and locks the cached object (if present). For objects stored in regions.

Namespace: Microsoft.Data.Caching
Assembly: ClientLibrary (in clientlibrary.dll)

Syntax

'Declaration
Public Function GetAndLock ( _
    key As String, _
    timeout As TimeSpan, _
    <OutAttribute> ByRef lockHandle As DataCacheLockHandle, _
    region As String _
) As Object
'Usage
Dim instance As DataCache
Dim key As String
Dim timeout As TimeSpan
Dim lockHandle As DataCacheLockHandle
Dim region As String
Dim returnValue As Object

returnValue = instance.GetAndLock(key, timeout, lockHandle, region)
public Object GetAndLock (
    string key,
    TimeSpan timeout,
    out DataCacheLockHandle lockHandle,
    string region
)
public:
Object^ GetAndLock (
    String^ key, 
    TimeSpan timeout, 
    [OutAttribute] DataCacheLockHandle^% lockHandle, 
    String^ region
)
public Object GetAndLock (
    String key, 
    TimeSpan timeout, 
    /** @attribute OutAttribute() */ /** @ref */ DataCacheLockHandle lockHandle, 
    String region
)
JScript does not support passing value-type arguments by reference.

Parameters

  • key
    The unique value that is used to identify the object in the region.
  • timeout
    A non-zero value indicating how many minutes the object remains locked.
  • lockHandle
    The DataCacheLockHandle object required to unlock the object. The lockHandle output parameter is passed by reference.
  • region
    The name of the region where the object resides.

Return Value

The object that was cached by using the specified key. Null is returned if the object has already been locked or the key does not exist.

Remarks

Other GetAndLock method calls on the same object fail as long as the lock is valid. Regular Get method calls are not blocked and always access the latest version of the cached object. For more information about concurrency, see Concurrency Models (Velocity) and Concurrency Methods (Velocity).

See Also

Reference

DataCache Class
DataCache Members
Microsoft.Data.Caching Namespace