Insert list of CacheItem to the cache

Namespace: Alachisoft.NCache.Web.Caching
Assembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: (


public override IDictionary InsertBulk(
	string[] keys,
	CacheItem[] items,
	DSWriteOption dsWriteOptions,
	string provider,
	DataSourceItemsUpdatedCallback onDataSourceItemUpdatedCallback
Visual Basic
Public Overrides Function InsertBulk ( 
	keys As String(),
	items As CacheItem(),
	dsWriteOptions As DSWriteOption,
	provider As String,
	onDataSourceItemUpdatedCallback As DataSourceItemsUpdatedCallback
) As IDictionary
Visual C++
virtual IDictionary^ InsertBulk(
	array<String^>^ keys, 
	array<CacheItem^>^ items, 
	DSWriteOption dsWriteOptions, 
	String^ provider, 
	DataSourceItemsUpdatedCallback^ onDataSourceItemUpdatedCallback
) override


Type: array<System..::..String>[]()[][]
The cache keys used to reference the items.
Type: array<Alachisoft.NCache.Web.Caching..::..CacheItem>[]()[][]
The items that are to be stored
Type: Alachisoft.NCache.Web.Caching..::..DSWriteOption
Type: System..::..String
Type: Alachisoft.NCache.Web.Caching..::..DataSourceItemsUpdatedCallback
A delegate that, if provided, is called when item is updated in data source.

Return Value

Type: IDictionary
returns keys that are added or updated successfully and their status.


If CacheItem contains invalid values the related exception is thrown. See CacheItem for invalid property values and related exceptions


The following example demonstrates how to assign an item high priority when you insert it into your application's Cache object.

Note: For more information about how to use this method with the CacheItemRemovedCallback delegate, see CacheItemRemovedCallback.

First create CacheItems.
 Copy imageCopy
string[] keys = {"SQLDSN", "ORADSN"};
CacheItem items[] = new CacheItem[2];
items[0] = new CacheItem(sqlConnectionString);
item.AbsoluteExpiration = DateTime.Now.AddMinutes(2);
item.Priority = CacheItemPriority.High;
item.ItemRemoveCallback = onRemove;

items[1] = new CacheItem(oraConnectionString);
item.AbsoluteExpiration = DateTime.Now.AddMinutes(1);
item.Priority = CacheItemPriority.Low;
item.ItemRemoveCallback = onRemove;
Then insert CacheItems to the cache
 Copy imageCopy
Cache cache = NCache.InitializeCache("myCache");
string[] keys = new string[]{"myItem1", "myItem2"};
CacheItem[] items = new CacheItem[]{myItem1, myItem2};
cache.InsertBulk(keys, items, DSWriteOption.WriteThru, providerName, new DataSourceItemsUpdatedCallback(onDSItemsUpdated));

See Also