• Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS
  • 文档
  • 比较
  • 博客
  • 尝试 NCache
  • 联系我们
尝试 NCache
显示/隐藏目录

方法 AddBulk

AddBulk(字典, WriteThruOptions)

添加缓存键字典 缓存项 使用 WriteThruOptions 到缓存。 CacheItem 包含与项目相关联的属性,如过期、依赖关系和驱逐信息。

声明
IDictionary<string, Exception> AddBulk(IDictionary<string, CacheItem> items, WriteThruOptions writeThruOptions = null)
参数
类型 姓名 描述
System.Collections.Generic.IDictionary<系统字符串, 缓存项> 项目

键和字典 缓存项. 键必须是唯一的。

直写选项 写直通选项

直写选项 关于更新数据源。 这可以是 WriteThru、WriteBehind 或无。

Returns & Exchanges
类型 描述
System.Collections.Generic.IDictionary<系统字符串, 系统异常>

无法存储在缓存中的键字典和异常。

例子

以下示例演示了如何将项目批量添加到缓存中。这些项目在 2 分钟后绝对过期,并且具有高优先级。

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.AddBulk(items, writeThruOptions);

联系我们

联系电话

+1 214-619-2601   (美国)

+44 20 7993 8327   (英国)

 
邮箱地址

sales@alachisoft.com

support@alachisoft.com

NCache
  • 版本比较
  • NCache 卓越
  • 基准
尝试 NCache
定价
NCache 兒童遊樂區

部署
  • 云端
  • Docker
  • Kubernetes
  • 内部部署
技术用例
  • ASP.NET 会话
  • ASP.NET Core 会话
  • 发布/订阅消息
  • SignalR 背板
  • 物联网(IOT)
  • NoSQL 数据库
  • 流处理
  • 微服务
相关资源
  • 博客
  • Foundations
  • 视频
  • 比较
  • 作品
  • 白皮书
  • 专题文章
  • 技术讲座
  • 杂志文章
  • 第三方文章
客户案例研究
  • 评价
  • 客户
支持
  • 文档
  • 安排演示
  • 小技巧
关于我们
  • 领导团队
  • 合作伙伴
  • 新闻
  • 活动
  • 加入我们
联系我们

  • 英语简体中文法语版德语版意大利语版日语版韩语版葡萄牙语西班牙语

  • 使用条款
  •  
  • 隐私政策
  •  
  • Cookie政策
©版权所有 Alachisoft 2002 - 版权所有。 NCache 是 Diyatech Corp. 的注册商标。
  • Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS