【发布时间】:2018-02-17 09:24:58
【问题描述】:
在 Ignite.NET 中,可以在“相同”节点缓存具有相同亲和力的键值对。是否可以定义应该使用的特定节点?
这是一个测试程序,我想定义一个节点来缓存关联“客户”,另一个节点来缓存关联“成员”。
class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
class Program
{
static void Main(string[] args)
{
using (var ignite = Ignition.Start())
{
var cache = ignite.GetOrCreateCache<AffinityKey, Person>(new CacheConfiguration("person-cache")
{
CacheMode = CacheMode.Partitioned,
});
cache.Put(new AffinityKey(1, "customer"), new Person { Name = "Test customer", Age = 7 });
cache.Put(new AffinityKey(1, "member"), new Person { Name = "Test member", Age = 7 });
foreach (var item in cache)
{
Console.WriteLine($"{item.Key}: {item.Value.Name} - {item.Value.Age}");
}
Console.ReadKey();
}
}
}
【问题讨论】: