NamedCacheAsyncExtensionsSetMetadataAsync Method (NamedCache, Guid, ObjectMetadata, Boolean, LockTicket, CancellationToken)

ScaleOut Software NamedCache API
Asynchronously creates or updates settable index values for a cached object; optionally unlocks the object. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.

Namespace:  Soss.Client.Extensions
Assembly:  soss_namedcache (in soss_namedcache.dll) Version: 6.2.0.0
Syntax

public static Task SetMetadataAsync(
	this NamedCache cache,
	Guid id,
	ObjectMetadata metadata,
	bool unlock,
	LockTicket lockTicket = null,
	CancellationToken cancellationToken = null
)

Parameters

cache
Type: Soss.ClientNamedCache
the NamedCache this extension method operates on.
id
Type: SystemGuid
a Guid that will be transformed into a CachedObjectId via CreateKey(Guid) which identifies the object in the cache.
metadata
Type: Soss.ClientObjectMetadata
The new metadata for the object, containing a collection of index values.
unlock
Type: SystemBoolean
If the object was previously locked with the current SossCahce and unlock is true then the object will be unlocked after the operation completes.
lockTicket (Optional)
Type: Soss.ClientLockTicket
An optional LockTicket obtained from a previous locking call
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
An optional CancellationToken that can be used to cancel the asynchronous operation.

Return Value

Type: Task

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type NamedCache. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions

ExceptionCondition
ObjectNotFoundExceptionThrown if the object to update does not exist in the shared cache.
ObjectLockedExceptionThrown if the lock on the cached object exceeded the 90 second timeout period and another client acquired the lock.
StateServerExceptionThrown if ScaleOut StateServer is unavailable or has experienced an internal error.
ArgumentNullExceptionThrown if metadata is null.
Remarks

The SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) method does not honor the UseLocking property. Use the AcquireLock(CachedObjectId) or Retrieve(CachedObjectId, Boolean) methods or their asynchronous equivalents prior to calling SetMetadataAsync(NamedCache, Guid, ObjectMetadata, Boolean, LockTicket, CancellationToken) if the object needs to be locked.

Care should be taken when performing unlocked metadata changes on objects. An unlocked SetMetadataAsync(NamedCache, Guid, ObjectMetadata, Boolean, LockTicket, CancellationToken) operation will not block for locks held by another clients, so other clients may have the object metadata changed underneath them despite the locks they hold.

See Also

Reference