NamedCache Class

ScaleOut Software NamedCache API
Provides access to a named collection of objects that can be shared globally across multiple clients.
Inheritance Hierarchy

SystemObject
  Soss.ClientNamedCache

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

public class NamedCache : IEnumerable

The NamedCache type exposes the following members.

Constructors

  NameDescription
Protected methodNamedCache
Creates a named cache with the given name and registers the cache with the CacheFactory.
Top
Properties

  NameDescription
Public propertyAllowClientCaching
Gets/sets an flag indicating whether (deserialized) objects accessed by this cache should be kept in a client-side cache when they are written to StateServer. Default is true.
Public propertyCount
Gets the number of elements contained in the cache.
Public propertyDefaultCreatePolicy
Public propertyDefaultGeoServerReadMode
Determines the GeoServer read behavior when using the NamedCache's indexer, Get(String) method, Retrieve(String, Boolean) overload, or GetMetadata(String, Boolean) overload to read cached items. Default is LocalDoNotThrowOnStaleData.
Public propertyEnableMethodInvocationEventHandling
Gets or sets a value indicating whether this NamedCache instance is enabled for receiving StateServer method invocation events.
Public propertyEnableObjectExpirationEventHandling
Gets or sets a value indicating whether this NamedCache instance is enabled for StateServer object expiration events.
Public propertyStatic memberInfiniteInvokeTimeout
The timeout value to supply when initiating and Invoke operation if you want the operation to be able to run forever.
Public propertyInvocationGrid
Gets or sets the InvocationGrid object, which is used by all Invoke Overload methods.
Public propertyItemByte
Gets or sets a cached item using default parameters.
Public propertyItemGuid
Gets or sets a cached item using default parameters.
Public propertyItemString
Gets or sets a cached item using default parameters.
Public propertyItemCachedObjectId
Gets or sets a cached item using default parameters.
Public propertyKeys
Returns a collection of keys for all the objects stored in the named cache.
Public propertyLockRetryInterval
Gets/Sets milliseconds between lock retries. Default is 5 milliseconds.
Public propertyMaxLockAttempts
Gets/Sets the number of lock attempts. The default is 20000 attempts.
Public propertyMaxReadThroughPendingAttempts
Gets/Sets the number of read attempts made when performing a read-through operation from a backing store or a remote read from another store using GeoServer pull replication. The default is 2400 attempts.
Public propertyName
Return this NamedCache's name.
Public propertyReadPendingRetryInterval
Gets/Sets milliseconds between read retries when backing store read-through operations are enabled or GeoServer pull replication is being used. Default is 50 milliseconds.
Protected propertySerializationCallbacks
Return the SerializationCallbacks in use for this NamedCache instance. If null, the default serialization mechanism will be used.
Public propertyUseLocking
Determines the locking behavior when using the NamedCache's indexer to get or set cached items. Default is false.
Public propertyValues
Returns the values of all objects stored in cache.
Top
Methods

  NameDescription
Public methodAcquireLock(Byte)
Locks the cached object in SOSS to prevent other clients from updating or removing it.
Public methodAcquireLock(Guid)
Locks the cached object in SOSS to prevent other clients from updating or removing it.
Public methodAcquireLock(String)
Locks the cached object in SOSS to prevent other clients from updating or removing it.
Public methodAcquireLock(CachedObjectId)
Locks the cached object in SOSS to prevent other clients from updating or removing it.
Public methodAcquireLockAsync
Asynchronously locks the cached object in SOSS to prevent other clients from updating or removing it.
Public methodCode exampleAdd(IDictionary)
Efficiently adds a large collection of objects to the cache.
Public methodAdd(Byte, Object)
Adds an item to the cache using default parameters. If the object already exists in the cache then it will be updated.
Public methodAdd(Guid, Object)
Adds an item to the cache using default parameters. If the object already exists in the cache then it will be updated.
Public methodAdd(String, Object)
Adds an item to the cache using default parameters. If the object already exists in the cache then it will be updated.
Public methodAdd(CachedObjectId, Object)
Adds an item to the cache using default parameters. If the object already exists in the cache then it will be updated.
Public methodClear
Clears the cache.
Public methodContains(Byte)
Checks if the cache contains an object with the given ID.
Public methodContains(Guid)
Checks if the cache contains an object with the given ID.
Public methodContains(String)
Checks if the cache contains an object with the given ID.
Public methodContains(CachedObjectId)
Checks if the cache contains an object with the given ID.
Protected methodCreateAsyncDataAccessor
Creates an NamedCacheDataAccessor instance corresponding to the given id for use in asynchronous API calls.
Protected methodCreateDataAccessor
Return a NamedCacheDataAccessor initialized to access the object identified by id. This method supports the ScaleOut API infrastructure and should not be overridden in your code.
Public methodCreateKey(Byte)
Generates a CachedObjectId for an object identified by id.
Public methodCreateKey(Guid)
Generates a CachedObjectId for an object identified by id.
Public methodCreateKey(String)
Generates a CachedObjectId for an object identified by id.
Public methodStatic memberCreateKey(StateServerKey)
Generates a CachedObjectId for an object identified by id.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGet(Byte)
Gets a cached object using default parameters.
Public methodGet(IEnumerable)
Gets multiple objects from the cache based on a collection of object identifiers. No locking is performed by this overload.
Public methodGet(Guid)
Gets a cached object using default parameters.
Public methodGet(String)
Gets a cached object using default parameters.
Public methodGet(CachedObjectId)
Gets a cached object using default parameters.
Public methodGetAllTags
Returns an enumeration of all tags known within this NamedCache.
Public methodGetEventSource
[Preview feature--subject to change] Returns an IObservable event source that can be used to process events in server-side applications. Clients can use the PostEvent(CachedObjectId, String, Byte, NullableTimeSpan) method to send events to the NamedCache's event source. The returned sequence never completes.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetMetadata(Byte, GetMetadataOptions)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(Byte, Boolean)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(Guid, GetMetadataOptions)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(Guid, Boolean)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(String, GetMetadataOptions)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(String, Boolean)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(CachedObjectId, GetMetadataOptions)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadata(CachedObjectId, Boolean)
Gets server metadata and user-defined index values for an object in the named cache.
Public methodGetMetadataAsync
Asynchronously gets server metadata and user-defined index values for an object in the named cache.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleInsert(Byte, Object, CreatePolicy, Boolean, Boolean)
Inserts a serializable object to a named cache. If an object with the same ID already exists in the cache then it can optionally be updated.
Public methodCode exampleInsert(Guid, Object, CreatePolicy, Boolean, Boolean)
Inserts a serializable object to a named cache. If an object with the same ID already exists in the cache then it can optionally be updated.
Public methodCode exampleInsert(String, Object, CreatePolicy, Boolean, Boolean)
Inserts a serializable object to a named cache. If an object with the same ID already exists in the cache then it can optionally be updated.
Public methodCode exampleInsert(CachedObjectId, Object, CreatePolicy, Boolean, Boolean)
Inserts a serializable object to a named cache. If an object with the same ID already exists in the cache then it can optionally be updated.
Public methodInvokeT, P(IFilter, P, ActionT, P, TimeSpan)
Invoke the user-defined evalMethod on all StateServer objects in this NamedCache that satisfy the Query(IFilter) constraints given by filter. Each method invocation will be passed the parameter object param.
Public methodInvokeT, P(IFilter, P, ActionT, P, EvalArgs, TimeSpan)
Invoke the user-defined evalMethod on all StateServer objects in this NamedCache that satisfy the Query(IFilter) constraints given by filter. Each method invocation will be passed the parameter object param.
Public methodInvokeT, P, R(IFilter, P, FuncT, P, R, FuncR, R, R, TimeSpan)
Invoke the user-defined evalMethod on all StateServer objects in this NamedCache that satisfy the Query(IFilter) constraints given by filter. Each method invocation will be passed the parameter object param.
Public methodInvokeT, P, R(IFilter, P, FuncT, P, EvalArgs, R, FuncR, R, R, TimeSpan)
Invoke the user-defined evalMethod on all StateServer objects in this NamedCache that satisfy the Query(IFilter) constraints given by filter. Each method invocation will be passed the parameter object param.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode examplePostEvent
Posts an event that is associated with a StateServer object. The event will be handled remotely on the host where the object resides. Server-side handlers of these events can use GetEventSource to acquire an IObservableT source to process the event stream.
Public methodPutAsync
Asynchronously creates or updates a serializable object within a named cache.
Public methodCode exampleQuery
Queries the cache for objects that have matching metadata IndexValues as specified via filter.
Public methodQueryAsync(IFilter, CancellationToken)
Asynchronously queries the cache for objects that have matching metadata IndexValues as specified via filter.
Public methodQueryAsyncT(IQueryableT, CancellationToken)
Asynchronously queries the cache for objects that match the Linq query query.
Public methodQueryKeysT
Filters a set of objects found in the StateServer within this NamedCache returning a sequence of typed, NamedCache keys (IQueryableT corresponding to only those objects that are instances of T.
Public methodQueryObjectsT
Filters a set of objects found in the StateServer within this NamedCache returning an IQueryableT sequence containing only those objects that are instances of T.
Public methodReleaseLock(Byte)
Releases the lock on a cached object.
Public methodReleaseLock(Guid)
Releases the lock on a cached object.
Public methodReleaseLock(String)
Releases the lock on a cached object.
Public methodReleaseLock(CachedObjectId)
Releases the lock on a cached object.
Public methodReleaseLockAsync
Asynchronously releases the lock on a cached object.
Public methodRemove(Byte)
Removes the object from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache.
Public methodRemove(Guid)
Removes the object from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache.
Public methodRemove(String)
Removes the object from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache.
Public methodRemove(CachedObjectId)
Removes the object from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache.
Public methodRemoveAsync
Asynchronously removes the object with the given id from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache.
Public methodRetrieve(Byte, RetrieveOptions)
Retrieves an object from the named cache.
Public methodRetrieve(Byte, Boolean)
Retrieves an object from the named cache.
Public methodRetrieve(Guid, RetrieveOptions)
Retrieves an object from the named cache.
Public methodRetrieve(Guid, Boolean)
Retrieves an object from the named cache.
Public methodRetrieve(String, RetrieveOptions)
Retrieves an object from the named cache.
Public methodRetrieve(String, Boolean)
Retrieves an object from the named cache.
Public methodRetrieve(CachedObjectId, RetrieveOptions)
Retrieves an object from the named cache.
Public methodRetrieve(CachedObjectId, Boolean)
Retrieves an object from the named cache.
Public methodRetrieveAsync
Asynchronously retrieves an object from the named cache.
Public methodSetBackingStoreAdapter
Specifies a class that can be used by the NamedCache to automatically interact with an external data source (a database, typically) for read-through, write-through, refresh-ahead, and write-behind operations.
Public methodCode exampleSetCustomSerialization
Establishes custom serialize/deserialize callbacks for objects in this NamedCache.
Public methodSetMetadata(Byte, ObjectMetadata, Boolean)
Creates and updates settable index values for a cached object and optionally unlocks the object.
Public methodSetMetadata(Guid, ObjectMetadata, Boolean)
Creates and updates settable index values for a cached object and optionally unlocks the object.
Public methodSetMetadata(String, ObjectMetadata, Boolean)
Creates and updates settable index values for a cached object and optionally unlocks the object.
Public methodSetMetadata(CachedObjectId, ObjectMetadata, Boolean)
Creates and updates settable index values for a cached object and optionally unlocks the object.
Public methodSetMetadataAsync
Asynchronously creates or updates settable index values for a cached object; optionally unlocks the object.
Public methodSetRemoteStores
Configures a list of remote stores that this NamedCache should use to look for objects that are not found in the local store. Read calls will check remote stores in the order that they are listed. If a missing object is found in one of the specified remote stores then it will be replicated to the local store using GeoServer pull replication.
Public methodSingleObjectInvokeT, P(CachedObjectId, P, ActionT, P, TimeSpan)
Invoke the user-defined method on the StateServer object identified by objectId within this NamedCache. The method invocation will be passed the parameter object param. In this overload, method has a void return.
Public methodSingleObjectInvokeT, P(CachedObjectId, P, ActionT, P, EvalArgs, TimeSpan)
Invoke the user-defined method on the StateServer object identified by objectId within this NamedCache. The method invocation will be passed the parameter object param. In this overload, method has a void return.
Public methodSingleObjectInvokeT, P, R(CachedObjectId, P, FuncT, P, R, TimeSpan)
Invoke the user-defined method on the StateServer object identified by objectId within this NamedCache. The method invocation will be passed the parameter object param. The result returned from method is returned to the caller of this method.
Public methodSingleObjectInvokeT, P, R(CachedObjectId, P, FuncT, P, EvalArgs, R, TimeSpan)
Invoke the user-defined method on the StateServer object identified by objectId within this NamedCache. The method invocation will be passed the parameter object param. The result returned from method is returned to the caller of this method.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdate(Byte, Object, UpdateOptions)
Updates an object in the named cache.
Public methodUpdate(Byte, Object, Boolean)
Updates an object in the named cache.
Public methodUpdate(Guid, Object, UpdateOptions)
Updates an object in the named cache.
Public methodUpdate(Guid, Object, Boolean)
Updates an object in the named cache.
Public methodUpdate(String, Object, UpdateOptions)
Updates an object in the named cache.
Public methodUpdate(String, Object, Boolean)
Updates an object in the named cache.
Public methodUpdate(CachedObjectId, Object, UpdateOptions)
Updates an object in the named cache.
Public methodUpdate(CachedObjectId, Object, Boolean)
Updates an object in the named cache.
Top
Events

  NameDescription
Public eventCode exampleObjectExpired
An event that is fired when an object cached within this NamedCache expires.
Top
Extension Methods

  NameDescription
Public Extension MethodAcquireLockAsync(String, LockTicket, CancellationToken)Overloaded.
Asynchronously locks the cached object in SOSS to prevent other clients from updating or removing it. This extension method is simply a convenience wrapper for AcquireLockAsync(CachedObjectId, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodAcquireLockAsync(Guid, LockTicket, CancellationToken)Overloaded.
Asynchronously locks the cached object in SOSS to prevent other clients from updating or removing it. This extension method is simply a convenience wrapper for AcquireLockAsync(CachedObjectId, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodAcquireLockAsync(Byte, LockTicket, CancellationToken)Overloaded.
Asynchronously locks the cached object in SOSS to prevent other clients from updating or removing it. This extension method is simply a convenience wrapper for AcquireLockAsync(CachedObjectId, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(String, GetMetadataOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(Guid, GetMetadataOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(Byte, GetMetadataOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(String, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that creates a CachedObjectId from id and interprets acquireLock setting GetMetadataOptions appropriately.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(Guid, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that creates a CachedObjectId from id and interprets acquireLock setting GetMetadataOptions appropriately.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(Byte, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that creates a CachedObjectId from id and interprets acquireLock setting GetMetadataOptions appropriately.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodGetMetadataAsync(CachedObjectId, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously gets server metadata and user-defined index values for an object in the named cache. This extension method is simply a convenience wrapper for GetMetadataAsync(CachedObjectId, GetMetadataOptions, LockTicket, CancellationToken) that interprets acquireLock and sets GetMetadataOptions appropriately.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodInsertAsync(String, Object, Boolean, Boolean, CreatePolicy, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which mimics the synchronous Insert(String, Object, CreatePolicy, Boolean, Boolean).
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodInsertAsync(Guid, Object, Boolean, Boolean, CreatePolicy, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which mimics the synchronous Insert(String, Object, CreatePolicy, Boolean, Boolean).
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodInsertAsync(Byte, Object, Boolean, Boolean, CreatePolicy, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which mimics the synchronous Insert(String, Object, CreatePolicy, Boolean, Boolean).
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodInsertAsync(CachedObjectId, Object, Boolean, Boolean, CreatePolicy, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which mimics the synchronous Insert(CachedObjectId, Object, CreatePolicy, Boolean, Boolean).
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodPutAsync(String, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which supplies DefaultCreatePolicy for an unspecified createPolicy and creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodPutAsync(Guid, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which supplies DefaultCreatePolicy for an unspecified createPolicy and creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodPutAsync(Byte, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which supplies DefaultCreatePolicy for an unspecified createPolicy and creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodPutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously creates or updates a serializable object within a named cache. This extension method is simply a convenience wrapper for PutAsync(CachedObjectId, Object, CreatePolicy, PutOptions, LockTicket, CancellationToken) which supplies defaults for various parameters.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodReleaseLockAsync(String, LockTicket, CancellationToken)Overloaded.
Asynchronously releases the lock on a cached object. This extension method is simply a convenience wrapper for ReleaseLockAsync(CachedObjectId, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodReleaseLockAsync(Guid, LockTicket, CancellationToken)Overloaded.
Asynchronously releases the lock on a cached object. This extension method is simply a convenience wrapper for ReleaseLockAsync(CachedObjectId, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodReleaseLockAsync(Byte, LockTicket, CancellationToken)Overloaded.
Asynchronously releases the lock on a cached object. This extension method is simply a convenience wrapper for ReleaseLockAsync(CachedObjectId, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRemoveAsync(String, IOptimisticConcurrencyVersionHolder, LockTicket, CancellationToken)Overloaded.
Asynchronously removes the object with the given id from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRemoveAsync(Guid, IOptimisticConcurrencyVersionHolder, LockTicket, CancellationToken)Overloaded.
Asynchronously removes the object with the given id from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRemoveAsync(Byte, IOptimisticConcurrencyVersionHolder, LockTicket, CancellationToken)Overloaded.
Asynchronously removes the object with the given id from the cache. No exception will be thrown and no action will be taken if the specified object does not exist in the cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(String, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of cache's UseLocking and DefaultGeoServerReadMode values and creates a CachedObjectId from the supplied id value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(Guid, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of cache's UseLocking and DefaultGeoServerReadMode values and creates a CachedObjectId from the supplied id value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(Byte, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of cache's UseLocking and DefaultGeoServerReadMode values and creates a CachedObjectId from the supplied id value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(CachedObjectId, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of cache's UseLocking and DefaultGeoServerReadMode values.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(String, RetrieveOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(Guid, RetrieveOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(Byte, RetrieveOptions, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) that creates a CachedObjectId from id.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(String, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of acquireLock and the cache's DefaultGeoServerReadMode value and creates a CachedObjectId from the supplied id value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(Guid, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of acquireLock and the cache's DefaultGeoServerReadMode value and creates a CachedObjectId from the supplied id value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(Byte, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of acquireLock and the cache's DefaultGeoServerReadMode value and creates a CachedObjectId from the supplied id value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodRetrieveAsync(CachedObjectId, Boolean, LockTicket, CancellationToken)Overloaded.
Asynchronously retrieves an object from the named cache. This extension method is simply a convenience wrapper for SetMetadataAsync(CachedObjectId, ObjectMetadata, Boolean, LockTicket, CancellationToken) which initializes RetrieveOptions based on the value of acquireLock and the cache's DefaultGeoServerReadMode value.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodSetMetadataAsync(String, ObjectMetadata, Boolean, LockTicket, CancellationToken)Overloaded.
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.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodSetMetadataAsync(Guid, ObjectMetadata, Boolean, LockTicket, CancellationToken)Overloaded.
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.
(Defined by NamedCacheAsyncExtensions.)
Public Extension MethodSetMetadataAsync(Byte, ObjectMetadata, Boolean, LockTicket, CancellationToken)Overloaded.
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.
(Defined by NamedCacheAsyncExtensions.)
Top
Remarks

The NamedCache class provides a collection-based API suitable for caching a group of objects within a single, named cache. The GetCache(String) method must be used to access a NamedCache instance.

Objects within a named cache are identified using IDs of type CachedObjectId. Object identifiers can be constructed from a variety of types such as strings, guids, and byte arrays, and they are constrained to identify objects within a single named cache.

A number of advanced caching features are available through the NamedCache class. When inserting an object into a cache, an expiration time for the object can be specified, as well the expiration behavior (sliding vs. absolute). Dependencies between objects can also be defined, allowing a dependent object to be automatically removed when one of its parent objects is updated or removed.

ScaleOut StateServer allows an object to be locked across every server in the farm. This per-object lock can be used to ensure that other clients do not alter the object while the lock is being held. All clients' code should take care to acquire a lock prior to performing an operation that could disrupt (or be disrupted by) other clients. The NamedCache will automatically perform retries when trying to acquire a lock.

The NamedCache class offers two properties to simplify usage of the advanced features of a named cache. The UseLocking property controls the default locking behavior for the ItemString accessor and Get(String) method, and the DefaultCreatePolicy property controls the default policies that are used when adding items to the cache through Add(String, Object) and ItemString. Finer grained control over locking and caching policies can be achieved by using the more advanced Insert(String, Object, CreatePolicy, Boolean, Boolean), Update(String, Object, Boolean), and Retrieve(String, Boolean) methods.

Every object in the cache can have up to 8 index values associated with it. Users are responsible for setting and managing these index values using the SetMetadata(String, ObjectMetadata, Boolean) method, and, once set, these index values can be queried for by using the Query(IFilter) method. The result of a Query operation is a collection of object identifiers that can be used to access the matching objects in the cache.

Under low-memory situations, ScaleOut StateServer can be configured to remove the least frequently used objects from the cache in order to free up room for newer ones. By default, all objects in the cache are subject to this reclamation, but this behavior can be overridden by setting the object's priority when the object is first added to the cache (see the CreatePolicy class used by Insert(String, Object, CreatePolicy, Boolean, Boolean) and DefaultCreatePolicy). See the "Configuration Parameters" topic in the SOSS help file for details on how to enable object reclamation in the server with the lru_threshold parameter.

Examples

using System;
using System.IO;
using System.Net;
using System.Text;
using Soss.Client;

class Program
{
    static void Main(string[] args)
    {
        // Looking up a stock quote via a web service is expensive,
        // so we check the cache to see if it has a fresh value:
        NamedCache cache = CacheFactory.GetCache("LatestQuotes");
        StockQuote msftQuote = cache["MSFT"] as StockQuote;

        if (msftQuote == null)
        {
            // Cache miss. Hit the web service for the stock price:
            msftQuote = downloadQuote("MSFT");

            // Set up the cache to hold on to quotes for 2 minutes:
            CreatePolicy cachePolicy = new CreatePolicy();
            cachePolicy.TimeoutMinutes = 2;
            cachePolicy.IsAbsoluteTimeout = true;
            cache.DefaultCreatePolicy = cachePolicy;

            // Objects added to the cache must be serializable:
            cache["MSFT"] = msftQuote;
        }

        Console.WriteLine("MSFT: " + msftQuote.LastPrice);
    }

    static StockQuote downloadQuote(string symbol)
    {
        const string url = "http://download.finance.yahoo.com/d/quotes.csv?s={0}&f=l1d1t1v";

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(url, symbol));
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream receiveStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

        // Stock data is returned as a comma-separated string. Split into array:
        string[] rawData = readStream.ReadToEnd().Split(new char[] { ',' });
        response.Close();
        readStream.Close();

        // Populate the StockQuote Object:
        StockQuote quote = new StockQuote();
        quote.LastPrice = decimal.Parse(rawData[0]);
        quote.LastTradeTime = DateTime.Parse(rawData[1].Replace("\"", "") + " " +
                                             rawData[2].Replace("\"", ""));
        quote.Volume = int.Parse(rawData[3]);
        return quote;
    }
}

[Serializable]
class StockQuote
{
    public decimal LastPrice = -1;
    public int Volume = -1;
    public DateTime LastTradeTime = DateTime.MinValue;
}
Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
See Also

Reference