Add array of CacheItem to the cache.
Namespace: Alachisoft.NCache.Web.CachingAssembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.1.0.0 (4.1.0.0)
Syntax
C# |
---|
protected internal virtual IDictionary AddBulkOperation( string[] keys, CacheItem[] items, DSWriteOption dsWriteOption, DataSourceItemsAddedCallback onDataSourceItemsAdded, string providerName ) |
Visual Basic |
---|
Protected Friend Overridable Function AddBulkOperation ( _ keys As String(), _ items As CacheItem(), _ dsWriteOption As DSWriteOption, _ onDataSourceItemsAdded As DataSourceItemsAddedCallback, _ providerName As String _ ) As IDictionary |
Visual C++ |
---|
protected public: virtual IDictionary^ AddBulkOperation( array<String^>^ keys, array<CacheItem^>^ items, DSWriteOption dsWriteOption, DataSourceItemsAddedCallback^ onDataSourceItemsAdded, String^ providerName ) |
Parameters
- keys
- Type: array<System..::..String>[]()[][]
The cache keys used to reference the items.
- items
- Type: array<Alachisoft.NCache.Web.Caching..::..CacheItem>[]()[][]
The items that are to be stored
- dsWriteOption
- Type: Alachisoft.NCache.Web.Caching..::..DSWriteOption
- onDataSourceItemsAdded
- Type: Alachisoft.NCache.Web.Caching..::..DataSourceItemsAddedCallback
A delegate that, if provided, is called when item is added to data source.
- providerName
- Type: System..::..String
Return Value
keys that are added or that alredy exists in the cache 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 add items to the cache with an absolute
expiration 2 minutes from now, a priority of
high, and that notifies the application when the item is removed from the cache.
First create a CacheItems.
Then add CacheItem to the cache
CopyC#
string keys = {"ORD_23", "ORD_67"}; CacheItem items = new CacheItem[2] items[0] = new CacheItem(new Order()); items[0].AbsoluteExpiration = DateTime.Now.AddMinutes(2); items[0].Priority = CacheItemPriority.High; items[0].ItemRemoveCallback = onRemove; items[1] = new CacheItem(new Order()); items[1].AbsoluteExpiration = DateTime.Now.AddMinutes(2); items[1].Priority = CacheItemPriority.Low; items[1].ItemRemoveCallback = onRemove;
CopyC#
OnDataSourceItemAdded(IDictionary result) { ... } Cache cache = NCache.InitializeCache("myCache"); cache.Add(keys, items, "Customer", "Orders", DataSourceUpdateOpt.WriteBehind, new DataSourceItemsAddedCallback(OnDataSourceItemAdded));