方法 RemoveBulk
RemoveBulk(IEnumerable , WriteThruOptions)
从 缓存. 您还可以指定写入选项,以便可以从缓存和数据源中删除项目。
声明
void RemoveBulk(IEnumerable<string> keys, WriteThruOptions writeThruOptions = null)
参数
| 类型 | 姓名 | 描述 |
|---|---|---|
| System.Collections.Generic.IEnumerable<系统字符串> | 键 | 引用项目的唯一键列表。 |
| 直写选项 | 写直通选项 | 直写选项 关于更新数据源。 这可以是 WriteThru、WriteBehind 或无。 |
例子
以下示例演示了如何从应用程序的 缓存 目的。
ICache cache = CacheManager.GetCache("demoClusteredCache");
List<string> keys = new List<string>()
{
"Product0",
"Product1",
"Product2"
};
WriteThruOptions writeThruOptions = new WriteThruOptions(WriteMode.WriteThru, "ProdDataSource1");
cache.RemoveBulk(keys, writeThruOptions);
例外
| 类型 | Condition |
|---|---|
| System.ArgumentNullException异常 | 键包含空引用。 |
| 系统参数异常 | 键不可序列化。 |
删除批量(IEnumerable , 出字典, WriteThruOptions)
从 Alachisoft.NCache.Client.Cache 并将它们以字典的形式作为输出参数返回给应用程序。
声明
void RemoveBulk<T>(IEnumerable<string> keys, out IDictionary<string, T> removedItems, WriteThruOptions writeThruOptions = null)
参数
| 类型 | 姓名 | 描述 |
|---|---|---|
| System.Collections.Generic.IEnumerable<系统字符串> | 键 | 引用项目的唯一键列表。 |
| System.Collections.Generic.IDictionary<系统字符串, T> | 已移除物品 | out 参数,通过该参数返回从缓存中删除的项目。 |
| 直写选项 | 写直通选项 | 直写选项 关于更新数据源。 这可以是 WriteThru、WriteBehind 或无。 |
类型参数
| 姓名 | 描述 |
|---|---|
| T | 指定从缓存中获取的值的类型。 |
备注
RemovedItems 字典包含从缓存中成功删除的项目的键和值。
例子
以下示例演示了如何从应用程序的 缓存 目的。
ICache cache = CacheManager.GetCache("demoClusteredCache");
List<string> keys = new List<string>()
{
"Product0",
"Product1",
"Product2"
};
WriteThruOptions writeThruOptions = new WriteThruOptions(WriteMode.WriteThru, "ProdDataSource1");
IDictionary<string, Product> products = null;
cache.RemoveBulk<Product>(keys,out products);
例外
| 类型 | Condition |
|---|---|
| System.ArgumentNullException异常 |
|
| 系统参数异常 |
|