Insert list 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# |
---|
public override IDictionary InsertBulk( string[] keys, CacheItem[] items, DSWriteOption dsWriteOptions, DataSourceItemsUpdatedCallback onDataSourceItemUpdatedCallback ) |
Visual Basic |
---|
Public Overrides Function InsertBulk ( _ keys As String(), _ items As CacheItem(), _ dsWriteOptions As DSWriteOption, _ onDataSourceItemUpdatedCallback As DataSourceItemsUpdatedCallback _ ) As IDictionary |
Visual C++ |
---|
public: virtual IDictionary^ InsertBulk( array<String^>^ keys, array<CacheItem^>^ items, DSWriteOption dsWriteOptions, DataSourceItemsUpdatedCallback^ onDataSourceItemUpdatedCallback ) override |
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
- dsWriteOptions
- Type: Alachisoft.NCache.Web.Caching..::..DSWriteOption
Options regarding updating data source
- onDataSourceItemUpdatedCallback
- Type: Alachisoft.NCache.Web.Caching..::..DataSourceItemsUpdatedCallback
Return Value
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.
Then insert CacheItems to the cache
Or simply in a class deriving from [!:Alachisoft.NCache.Web.UI.NPage] or [!:Alachisoft.NCache.Web.UI.NUserControl].
Note: For more information about how to use this method with the CacheItemRemovedCallback delegate, see CacheItemRemovedCallback.
First create CacheItems.CopyC#
string[] keys = {"SQLDSN", "ORADSN"}; CacheItem items[] = new CacheItem[2]; items[0] = new CacheItem(sqlConnectionString); item.AbsoluteExpiration = DateTime.Now.AddMinutes(2); item.SlidingExpiration = TimeSpan.Zero; item.Priority = CacheItemPriority.High; item.ItemRemoveCallback = onRemove; items[1] = new CacheItem(oraConnectionString); item.AbsoluteExpiration = DateTime.Now.AddMinutes(1); item.SlidingExpiration = TimeSpan.Zero; item.Priority = CacheItemPriority.Low; item.ItemRemoveCallback = onRemove;
CopyC#
NCache.Cache.Insert(keys, items, "Connection", null);
CopyC#
Cache.Insert(keys, items, "Connection", null);