Soss.Client.ConcurrentNamedMapTKey, TValue
Namespace: Soss.Client.Concurrent
Assembly: soss_namedcache (in soss_namedcache.dll) Version: 6.2.0.0
Type Parameters
- TKey
- The type of keys in the map.
- TValue
- The type of values in the map.
The NamedMapTKey, TValue type exposes the following members.
Name | Description | |
---|---|---|
NamedMapTKey, TValue(String) |
Creates a new instance of the NamedMapTKey, TValue class corresponding to the given name.
The instance uses default serializers based on the BinaryFormater class.
| |
NamedMapTKey, TValue(String, CustomSerializerTKey, CustomSerializerTValue) |
Creates a new instance of the NamedMapTKey, TValue class corresponding to the given name
and assigns custom key and value serializers to it.
|
Name | Description | |
---|---|---|
AutoCorrectStreamPosition |
Controls the stream reading behavior when the serialized key/value elements
are retrieved from in-memory data grid as the memory stream chunks. When using
either XML-based or Json-like custom serializers to serialize keys or values, it might be necessary
for NamedMapTKey, TValue to control the memory stream position after reading
an individual key or its value out of memory stream.
| |
AvailabilityMode |
Controls whether object replication is enabled for the named map.
Enabling replication provides fault tolerance, i.e., it ensures that no data is lost in case of host failure at the expense of increased memory and network utilization. If replication is enabled (AvailabilityMode.UseReplicas), the number of replicas created is controlled by the max_replicas parameter in the ScaleOut StateServer configuration. By default, object replication is enabled. | |
ClientCacheSize |
Gets and sets the maximum number of key/value entries in the client cache.
Client cache size is set to 10000 by default.
| |
CoherencyIntervalMilliseconds |
Gets and sets coherency interval, i.e., the maximum allowed time between the last server read request
and a TryGetValue(TKey, TValue) request before the client will
retrieve the object from the server instead of the client cache (if present).
A coherency interval of 0 means that the values are never served out of the client cache.
Coherency interval is set to 0 by default, so TryGetValue(TKey, TValue)
always retrieves latest value from the server.
| |
InvocationGrid |
Gets or sets the InvocationGrid object, which is used by parallel method invocations
(InvokeTParam, TResult(NamedMapInvokableTKey, TValue, TParam, TResult, TParam))
and parallel queries (ExecuteParallelQuery(QueryConditionTKey, TValue)).
| |
KeySerializer |
Gets the CustomSerializerT used to serialize and deserialize keys.
Custom serializers can be assigned to the NamedMapTKey, TValue via the
NamedMapTKey, TValue(String, CustomSerializerTKey, CustomSerializerTValue)
public constructor.
| |
MapID |
Returns the integer value used as the identifier of the named map.
| |
MapName |
Gets the map name.
| |
MaxServerRetries |
Sets the maximum number of server request retries when a race condition between client requests occur.
| |
ParallelOperationTransport |
Allows specify the transport protocol for parallel operations during
the InvokeTParam, TResult(NamedMapInvokableTKey, TValue, TParam, TResult, TParam)
or ExecuteParallelQuery(QueryConditionTKey, TValue)
method calls.
By default this property is set to ParallelOperationTransport.UseSockets.
| |
ValueSerializer |
Gets the CustomSerializerT used to serialize and deserialize values.
Custom serializers can be assigned to the NamedMapTKey, TValue via the
NamedMapTKey, TValue(String, CustomSerializerTKey, CustomSerializerTValue)
public constructor.
|
Name | Description | |
---|---|---|
AddOrUpdate(TKey, FuncTKey, TValue, FuncTKey, TValue, TValue) |
Adds a key/value pair to NamedMapTKey, TValue if the key does not already exist,
or updates a key/value pair in the NamedMapTKey, TValue if the key already exists.
| |
AddOrUpdate(TKey, TValue, FuncTKey, TValue, TValue) |
Adds a key/value pair to the NamedMapTKey, TValue if the key does not already exist,
or updates a key/value pair in the NamedMapTKey, TValue if the key already exists.
| |
Clear |
Removes all keys and values from the NamedMapTKey, TValue.
| |
ContainsKey |
Determines whether the NamedMapTKey, TValue
contains the specified key.
| |
ContainsValue |
Returns true if there are one or more keys with the specified value.
Note: this method requires that InvocationGrid is assigned to the NamedMapTKey, TValue. | |
CreateBulkLoader |
Gets the BulkLoaderTKey, TValue view of the NamedMapTKey, TValue"/>,
which can be used to efficiently put a large number of keys in the map.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
ExecuteCount |
Retrieves the number of key/value pairs contained in the NamedMapTKey, TValue.
| |
ExecuteParallelQuery(QueryConditionTKey, TValue) |
Runs a query on the map contents with the specified QueryConditionTKey, TValue.
The operation has an infinite timeout.
If QueryConditionTKey, TValue is null, all map's keys will be returned.
Note: this method requires that an InvocationGrid is assigned to the NamedMapTKey, TValue. | |
ExecuteParallelQuery(QueryConditionTKey, TValue, TimeSpan) |
Runs a query on the map contents with the specified QueryConditionTKey, TValue.
If QueryConditionTKey, TValue is null, all map's keys will be returned.
Note: this method requires that InvocationGrid is assigned to the NamedMapTKey, TValue. | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetKeysForValue |
Searches for a specific value in the map and returns all keys this value is associated with.
Note: this method requires that InvocationGrid is assigned to the NamedMapTKey, TValue. | |
GetOrAdd(TKey, FuncTKey, TValue) |
Adds a key/value pair to the NamedMapTKey, TValue
if the key does not already exist.
| |
GetOrAdd(TKey, TValue) |
Adds a key/value pair to the NamedMapTKey, TValue
if the key does not already exist.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InvokeTParam, TResult(NamedMapInvokableTKey, TValue, TParam, TResult, TParam) |
Runs a parallel method invocation on the map contents and returns the result. The operation has an infinite timeout.
The Eval and Merge methods should be defined by the instance of the
NamedMapInvokableTKey, TValue, TParam, TResult class.
Note: this method requires that InvocationGrid is assigned to the NamedMapTKey, TValue. | |
InvokeTParam, TResult(NamedMapInvokableTKey, TValue, TParam, TResult, TParam, TimeSpan) |
Runs a parallel method invocation on the map contents and returns the result.
The Eval and Merge methods should be defined via passing instance of the
NamedMapInvokableTKey, TValue, TParam, TResult class.
Note: this method requires that InvocationGrid is assigned to the NamedMapTKey, TValue. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
PutAll |
Efficiently puts contents of the specified map into the named map. This method should be
preferred to TryAdd(TKey, TValue) when updating the map with a large
number of keys and values. If the named map already contains a mapping for a key, its value
will be replaced with the value in the input map.
| |
RetrieveAllKeys |
Retrieves the collection of keys in the NamedMapTKey, TValue from the ScaleOut StateServer service.
| |
RunMapReduceMK, MV, OK, OV(NamedMapOK, OV, MapperTKey, TValue, MK, MV, CombinerMK, MV, ReducerMK, MV, OK, OV, TimeSpan) |
Provides a simple and fast way to perform a MapReduce operation that does not require Hadoop infrastructure.
| |
RunMapReduceMK, MV, OK, OV(NamedMapTKey, TValue, NamedMapOK, OV, MapperTKey, TValue, MK, MV, CombinerMK, MV, ReducerMK, MV, OK, OV, TimeSpan) |
Provides a simple and fast way to perform a MapReduce operation that does not require Hadoop infrastructure.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
TryAdd |
Attempts to add the specified key and value to the NamedMapTKey, TValue.
| |
TryGetValue |
Attempts to get the value associated with the specified key from the NamedMapTKey, TValue.
| |
TryRemove(TKey) |
Attempts to remove the value with the specified key from the NamedMapTKey, TValue.
| |
TryRemove(TKey, RemoveBehavior, TValue) |
Attempts to remove and return the value with the specified key from the NamedMapTKey, TValue.
If the parameter is set to the
RemoveBehaviorOptions.DoNotReturnValue, the value is removed and is not returned via the
value parameter to optimize the method call performance.
| |
TryUpdate(TKey, TValue) |
Updates the key with a newValue value.
| |
TryUpdate(TKey, TValue, TValue) |
Compares the existing value for the specified key with a specified value,
and if they are equal, updates the key with a third value.
|
Objects that are in a NamedMap are stored with minimal overhead and at much higher densities in the ScaleOut StateServer service than objects that are stored using the traditional NamedCache API. Since internal object metadata is minimized for NamedMap objects, individual objects do not have the same rich features that are available in the NamedCache API. But this allows much higher numbers of objects to be stored in memory and enables faster parallel access in your application.
using System; using Soss.Client.Concurrent; // Sample class to be put into the SOSS store. [Serializable] class SampleClass { public int IntVal; public double DoubleVal; public string StringVal; } class NamedMapBasicOps { static void Main(string[] args) { // Initialize object to be stored: SampleClass sampleObj = new SampleClass(); sampleObj.IntVal = 2014; sampleObj.DoubleVal = 7.25; sampleObj.StringVal = "Original value"; NamedMap<string, SampleClass> nm = new NamedMap<string, SampleClass>("myMap"); // Add the sampleObj to the named map: if (nm.TryAdd("key1", sampleObj) == true) Console.WriteLine("Object was successfully added to the named map."); else Console.WriteLine("An unexpected element with the same key already exists."); // Read this key/value pair from the map: SampleClass retObj = null; bool objFound = nm.TryGetValue("key1", out retObj); if (objFound) Console.WriteLine("Object was successfully retrieved from the named map."); else Console.WriteLine("Warning: The object was unexpectedly not found."); // Update the object in the named map: retObj = nm.AddOrUpdate("key1", (k) => { // This "addValueFactory" callback won't be called because we're doing an update Console.WriteLine("Warning: item unexpectedly not found during update."); return new SampleClass(); }, (k, v) => { // The "updateValueFactory" lambda used to modify our existing object: v.IntVal = v.IntVal * -1; v.DoubleVal = v.DoubleVal * -1; v.StringVal = "Updated value"; return v; }); // Remove the object from the map: bool objRemoved = nm.TryRemove("key1"); if (objFound) Console.WriteLine("Object successfully removed from the named map."); else Console.WriteLine("Warning: The removal failed unexpectedly."); } }