Language

Cache.GetAndLock Method (String, TimeSpan, out LockHandle)

[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: System.Data.Caching
Assembly: ClientLibrary (in clientlibrary.dll)

Syntax

'Declaration
Public Function GetAndLock ( _
    key As String, _
    lockTimeOut As TimeSpan, _
    <OutAttribute> ByRef lockHandle As LockHandle _
) As Object
'Usage
Dim instance As Cache
Dim key As String
Dim lockTimeOut As TimeSpan
Dim lockHandle As LockHandle
Dim returnValue As Object

returnValue = instance.GetAndLock(key, lockTimeOut, lockHandle)
public Object GetAndLock (
    string key,
    TimeSpan lockTimeOut,
    out LockHandle lockHandle
)
public:
Object^ GetAndLock (
    String^ key, 
    TimeSpan lockTimeOut, 
    [OutAttribute] LockHandle% lockHandle
)
public Object GetAndLock (
    String key, 
    TimeSpan lockTimeOut, 
    /** @attribute OutAttribute() */ /** @ref */ LockHandle 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.
  • lockTimeOut
    A non-zero value indicating how many minutes the object remains locked.
  • lockHandle
    The LockHandle 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

Cache Class
Cache Members
System.Data.Caching Namespace