Language

Cache.GetAndLock Method (String, 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 from a region (if present).

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

Syntax

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

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

Parameters

  • region
    The name of the region where the cached object is located. Use DefaultRegion if the object is not stored in a region.
  • key
    The unique value that is used to identify the object in the region or 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