Method Insert
Insert(IDictionary<TKey, TValue>)
Insert elements with the provided keys and values in IDistributedDictionary.
Declaration
void Insert(IDictionary<TKey, TValue> entries)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | entries | Elements to be insert in IDistributedDictionary. |
Examples
The following code sample shows how to insert multiple entries in distributed dictionary.
ICache cache = CacheManager.GetCache("myCache");
string dataTypeName = "DistributedDictionary";
IDistributedDictionary<string, Product> dictionary = cache.DataTypeManager.GetDictionary<string, Product>(dataTypeName);
// Create dictionary of new products to be added
IDictionary<string, Product> newProducts = new Dictionary<string, Product>();
Product[] products = FetchProducts();
foreach (var product in products)
{
// Add new products
string productKey = "$Product:{product.ProductID}";
newProducts.Add(productKey, product);
}
dictionary.Insert(newProducts);