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

[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).

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 _
) As Object
'Usage
Dim instance As DataCache
Dim key As String
Dim timeout As TimeSpan
Dim lockHandle As DataCacheLockHandle
Dim returnValue As Object

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

Parameters

  • key
    The unique value that is used to identify the object in the cache.
  • 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.

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