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

 

Lock the key if key is present and it is not locked by any clients and returns the object corresponding to the key.

Namespace:   Microsoft.ApplicationServer.Caching
Assembly:  Microsoft.ApplicationServer.Caching.Client (in Microsoft.ApplicationServer.Caching.Client.dll)

Syntax

public object GetAndLock(
    string key,
    TimeSpan timeout,
    out DataCacheLockHandle lockHandle,
    bool forceLock
)
public:
Object^ GetAndLock(
    String^ key,
    TimeSpan timeout,
    [OutAttribute] DataCacheLockHandle^% lockHandle,
    bool forceLock
)
member GetAndLock : 
        key:string *
        timeout:TimeSpan *
        lockHandle:DataCacheLockHandle byref *
        forceLock:bool -> Object
Public Function GetAndLock (
    key As String,
    timeout As TimeSpan,
    <OutAttribute> ByRef lockHandle As DataCacheLockHandle,
    forceLock As Boolean
) As Object

Parameters

  • key
    Type: System.String

    The unique value that is used to identify the object in the region.

  • timeout
    Type: System.TimeSpan

    The amount of time that object remains locked.

  • forceLock
    Type: System.Boolean

    If forceLock is true, key is locked irrespective of key-value pair presence in cache.

Return Value

Type: System.Object

Returns Object matching the specified key parameter if the Object is present and is not locked.

  • If the key does not exist, a DataCacheException object is thrown with the ErrorCode set to KeyDoesNotExist. Create objects based on the referenced key to resolve this error.

  • If the object is already locked by another cache client, a DataCacheException object is thrown with the ErrorCode set to ObjectLocked. The object will be inaccessible until it is unlocked by the locking client.

See Also

GetAndLock Overload
DataCache Class
Microsoft.ApplicationServer.Caching Namespace

Return to top