Try Playground
Show / Hide Table of Contents

Method InsertBulk

InsertBulk(IDictionary<String, CacheItem>, WriteThruOptions)

Inserts a dictionary of cache keys with CacheItem to the cache with the WriteThruOptions. The CacheItem contains properties to associate with the item, like expiration, dependencies and eviction information.

Declaration
IDictionary<string, Exception> InsertBulk(IDictionary<string, CacheItem> items, WriteThruOptions writeThruOptions = null)
Parameters
Type Name Description
System.Collections.Generic.IDictionary<System.String, CacheItem> items

Dictionary of keys and CacheItem. Keys must be unique.

WriteThruOptions writeThruOptions

WriteThruOptions regarding updating data source. This can be WriteThru, WriteBehind or none.

Returns
Type Description
System.Collections.Generic.IDictionary<System.String, System.Exception>

Dictionary of keys along with exception that were unable to store in cache.

Remarks

If the key or multilple keys already exist, this overload overwrites the values of the existing ICache items. If the key does not exist, it adds the item to the cache.

Examples

The following example demonstrates how to insert items to the cache with an absolute expiration of 2 minutes from now, a priority of high.

ICache cache = CacheManager.GetCache("demoClusteredCache");

CacheItem[] cacheItems = new CacheItem[3];

Product product_1 = new Product();
product_1.Id = 1;
product_1.Name = "Chai";

Product product_2 = new Product();
product_2.Id = 2;
product_2.Name = "Chang";

Product product_3 = new Product();
product_3.Id = 2;
product_3.Name = "Aniseed Syrup";

cacheItems[0] = new CacheItem(product_1);
cacheItems[0].Expiration = new Expiration(ExpirationType.Absolute, new TimeSpan(0, 2, 0));
cacheItems[0].Priority = CacheItemPriority.High;

cacheItems[1] = new CacheItem(product_2);
cacheItems[1].Expiration = new Expiration(ExpirationType.Absolute, new TimeSpan(0, 2, 0));
cacheItems[1].Priority = CacheItemPriority.Normal;

cacheItems[2] = new CacheItem(product_3);
cacheItems[2].Expiration = new Expiration(ExpirationType.Absolute, new TimeSpan(0, 2, 0));
cacheItems[2].Priority = CacheItemPriority.Low;

IDictionary<string, CacheItem> items = new Dictionary<string, CacheItem>()
{
    { "Product0",cacheItems[0]},
    { "Product1",cacheItems[1]},
    { "Product2",cacheItems[2]}
}

WriteThruOptions writeThruOptions = new WriteThruOptions(WriteMode.WriteThru, "ProdDataSource1");

cache.InsertBulk(items, writeThruOptions);
In This Article
  • InsertBulk(IDictionary<String, CacheItem>, WriteThruOptions)

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
� Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top