Method InsertBulk
InsertBulk(String[], CacheItem[], DSWriteOption, DataSourceItemsUpdatedCallback)
Insert list of CacheItem to the cache
Declaration
[TargetMethod(1)]
public virtual IDictionary InsertBulk(string[] keys, CacheItem[] items, DSWriteOption dsWriteOption, DataSourceItemsUpdatedCallback onDataSourceItemUpdatedCallback)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | keys | The cache keys used to reference the items. |
CacheItem[] | items | The items that are to be stored |
DSWriteOption | dsWriteOption | Options regarding updating data source |
DataSourceItemsUpdatedCallback | onDataSourceItemUpdatedCallback | A delegate that, if provided, is called when item is updated in data source. |
Returns
Type | Description |
---|---|
System.Collections.IDictionary | returns keys that are added or updated successfully and their status. |
Remarks
If CacheItem contains invalid values the related exception is thrown. See CacheItem for invalid property values and related exceptions
Examples
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.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
Cache cache = NCache.InitializeCache("myCache");
string[] keys = new string[]{"myItem1", "myItem2"};
CacheItem[] items = new CacheItem[]{myItem1, myItem2};
cache.InsertBulk(keys, items, DSWriteOption.WriteThru, new DataSourceItemsUpdatedCallback(onDSItemsUpdated));
InsertBulk(String[], CacheItem[])
Insert list of CacheItem to the cache
Declaration
[TargetMethod(2)]
public virtual IDictionary InsertBulk(string[] keys, CacheItem[] items)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | keys | The cache keys used to reference the items. |
CacheItem[] | items | The items that are to be stored |
Returns
Type | Description |
---|---|
System.Collections.IDictionary | returns keys that are added or updated successfully and their status. |
Remarks
If CacheItem contains invalid values the related exception is thrown. See CacheItem for invalid property values and related exceptions
Examples
The following example demonstrates how to assign an item high priority when you insert it into your application's Cache object. First create CacheItems.
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
Cache cache = NCache.InitializeCache("myCache");
string[] keys = new string[]{"myItem1", "myItem2"};
CacheItem[] items = new CacheItem[]{myItem1, myItem2};
cache.InsertBulk(keys, items);
InsertBulk(String[], CacheItem[], DSWriteOption, String, DataSourceItemsUpdatedCallback)
Insert list of CacheItem to the cache
Declaration
[TargetMethod(3)]
public virtual IDictionary InsertBulk(string[] keys, CacheItem[] items, DSWriteOption dsWriteOption, string providerName, DataSourceItemsUpdatedCallback onDataSourceItemUpdatedCallback)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | keys | The cache keys used to reference the items. |
CacheItem[] | items | The items that are to be stored |
DSWriteOption | dsWriteOption | Options regarding updating data source |
System.String | providerName | A unique identifier for the data source |
DataSourceItemsUpdatedCallback | onDataSourceItemUpdatedCallback | A delegate that, if provided, is called when item is updated in data source. |
Returns
Type | Description |
---|---|
System.Collections.IDictionary | returns keys that are added or updated successfully and their status. |
Remarks
If CacheItem contains invalid values the related exception is thrown. See CacheItem for invalid property values and related exceptions
Examples
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.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
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));