本文整理汇总了C#中ClientConfig.AddNearCacheConfig方法的典型用法代码示例。如果您正苦于以下问题:C# ClientConfig.AddNearCacheConfig方法的具体用法?C# ClientConfig.AddNearCacheConfig怎么用?C# ClientConfig.AddNearCacheConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClientConfig
的用法示例。
在下文中一共展示了ClientConfig.AddNearCacheConfig方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMapConfigWildcardMultipleAmbiguousConfigs
public virtual void TestMapConfigWildcardMultipleAmbiguousConfigs()
{
NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast*");
NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("*com.hazelcast");
ClientConfig config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig1);
config.AddNearCacheConfig(nearCacheConfig2);
config.GetNearCacheConfig("com.hazelcast");
}
示例2: TestDuplicateConfig
public virtual void TestDuplicateConfig()
{
NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast.*ap");
NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast*map");
ClientConfig config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig1);
config.AddNearCacheConfig(nearCacheConfig2);
config.GetNearCacheConfig("com.hazelcast.map");
}
示例3: TestSpecificNearCacheConfig_whenAsteriskAtTheBeginning
public virtual void TestSpecificNearCacheConfig_whenAsteriskAtTheBeginning()
{
var clientConfig = new ClientConfig();
var genericNearCacheConfig = new NearCacheConfig();
genericNearCacheConfig.SetName("*Map");
clientConfig.AddNearCacheConfig(genericNearCacheConfig);
var specificNearCacheConfig = new NearCacheConfig();
specificNearCacheConfig.SetName("*MapStudent");
clientConfig.AddNearCacheConfig(specificNearCacheConfig);
var mapFoo = clientConfig.GetNearCacheConfig("fooMap");
var mapStudentFoo = clientConfig.GetNearCacheConfig("fooMapStudent");
Assert.AreEqual(genericNearCacheConfig, mapFoo);
Assert.AreEqual(specificNearCacheConfig, mapStudentFoo);
}
示例4: TestNearCacheConfigWildcard3
public virtual void TestNearCacheConfigWildcard3()
{
NearCacheConfig nearCacheConfig = new NearCacheConfig().SetName("com.hazelcast.test.*");
ClientConfig config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig);
Assert.AreEqual(nearCacheConfig, config.GetNearCacheConfig("com.hazelcast.test.myNearCache"));
}
示例5: Run
public static void Run(string[] args)
{
Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");
var config = new ClientConfig();
var nearCacheConfig = new NearCacheConfig();
nearCacheConfig.SetMaxSize(1000)
.SetInvalidateOnChange(true)
.SetEvictionPolicy("Lru")
.SetInMemoryFormat(InMemoryFormat.Binary);
config.AddNearCacheConfig("nearcache-map-*", nearCacheConfig);
config.GetNetworkConfig().AddAddress("127.0.0.1");
var client = HazelcastClient.NewHazelcastClient(config);
var map = client.GetMap<string, string>("nearcache-map-1");
for (var i = 0; i < 1000; i++)
{
map.Put("key" + i, "value" + i);
}
var sw = new Stopwatch();
sw.Start();
for (var i = 0; i < 1000; i++)
{
map.Get("key" + i);
}
Console.WriteLine("Got values in " + sw.ElapsedMilliseconds + " millis");
sw.Restart();
for (var i = 0; i < 1000; i++)
{
map.Get("key" + i);
}
Console.WriteLine("Got cached values in " + sw.ElapsedMilliseconds + " millis");
map.Destroy();
client.Shutdown();
}
示例6: TestSpecificNearCacheConfig_whenAsteriskInTheMiddle
public virtual void TestSpecificNearCacheConfig_whenAsteriskInTheMiddle()
{
var clientConfig = new ClientConfig();
var genericNearCacheConfig = new NearCacheConfig();
genericNearCacheConfig.SetName("map*Bar");
clientConfig.AddNearCacheConfig(genericNearCacheConfig);
var specificNearCacheConfig = new NearCacheConfig();
specificNearCacheConfig.SetName("mapStudent*Bar");
clientConfig.AddNearCacheConfig(specificNearCacheConfig);
var mapFoo = clientConfig.GetNearCacheConfig("mapFooBar");
var mapStudentFoo = clientConfig.GetNearCacheConfig("mapStudentFooBar");
Assert.AreEqual(genericNearCacheConfig, mapFoo);
Assert.AreEqual(specificNearCacheConfig, mapStudentFoo);
}
示例7: TestNearCacheConfigWildcardMatchingPointEndsWith
public virtual void TestNearCacheConfigWildcardMatchingPointEndsWith()
{
NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("*.sub");
NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("*.test.sub");
NearCacheConfig nearCacheConfig3 = new NearCacheConfig().SetName("*.hazelcast.test.sub");
ClientConfig config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig1);
config.AddNearCacheConfig(nearCacheConfig2);
config.AddNearCacheConfig(nearCacheConfig3);
// we should not match any of the configs (endsWith)
Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelFast.Fast.sub.myNearCache"));
Assert.AreEqual(null, config.GetNearCacheConfig("hazelFast.test.sub.myNearCache"));
Assert.AreEqual(null, config.GetNearCacheConfig("test.sub.myNearCache"));
}
示例8: TestNearCacheConfigWithoutWildcard
public virtual void TestNearCacheConfigWithoutWildcard()
{
NearCacheConfig nearCacheConfig = new NearCacheConfig().SetName("someNearCache");
ClientConfig config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig);
Assert.AreEqual(nearCacheConfig, config.GetNearCacheConfig("someNearCache"));
// non-matching name
Assert.AreNotEqual(nearCacheConfig, config.GetNearCacheConfig("doesNotExist"));
// non-matching case
Assert.AreNotEqual(nearCacheConfig, config.GetNearCacheConfig("SomeNearCache"));
}
示例9: TestNearCacheConfigWildcardOnlyMultipleConfigs
public virtual void TestNearCacheConfigWildcardOnlyMultipleConfigs()
{
NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("*");
NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast.*");
ClientConfig config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig1);
config.AddNearCacheConfig(nearCacheConfig2);
// we should get the best matching result
Assert.AreEqual(nearCacheConfig2, config.GetNearCacheConfig("com.hazelcast.myNearCache"));
}
示例10: TestNearCacheConfigWildcardMatchingPointStartsWith
public virtual void TestNearCacheConfigWildcardMatchingPointStartsWith()
{
var nearCacheConfig1 = new NearCacheConfig().SetName("hazelcast.*");
var nearCacheConfig2 = new NearCacheConfig().SetName("hazelcast.test.*");
var nearCacheConfig3 = new NearCacheConfig().SetName("hazelcast.test.sub.*");
var config = new ClientConfig();
config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
config.AddNearCacheConfig(nearCacheConfig1);
config.AddNearCacheConfig(nearCacheConfig2);
config.AddNearCacheConfig(nearCacheConfig3);
// we should not match any of the configs (startsWith)
Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.myNearCache"));
Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.test.myNearCache"));
Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.test.sub.myNearCache"));
}
示例11: ConfigureClient
protected override void ConfigureClient(ClientConfig config)
{
base.ConfigureClient(config);
var nearCacheConfig = new NearCacheConfig().SetInMemoryFormat(InMemoryFormat.Object);
config.AddNearCacheConfig("nearCachedMap*", nearCacheConfig);
}