无法从群集中的不同计算机访问缓存键/值 [英] Unable to access cache key/value from separate machines in cluster
问题描述
我已将我的缓存群集配置如下(工作组,appfabric beta2,win2008,xml配置)。我写了一个非常简单的应用程序来将一个键/值对添加到缓存中。当我在Server1上设置密钥时,我希望它可以从server2获得。但是,我得到的值与我在Server2上设置的相同,与Server1上的相同。我没有正确使用DataCacheServerEndpoint来指定我的主机吗? (或者我只指定1台主机,其中集群的xml是?)我是否需要运行(之前使用Use-CacheCluster,因此我可以访问集群?)如何跨多个访问相同的缓存数据?电脑?对不起,我很沮丧,网上的例子只显示1台计算机访问缓存,当多台计算机应该能够...谢谢。
I have configured my Cache cluster as below (workgroup, appfabric beta2, win2008, xml config). I wrote a very simple app to add a key/value pair into cache. When I set the key on Server1, I'd expect it to be available from server2. However I am unable to get the same value that I set given the same key on Server2 as I get on Server1. Am I not using DataCacheServerEndpoint correctly to specify my host computers? (or do I just specify 1 host computer, where the xml for the cluster is?) do I need to run a (Use-CacheCluster before, so I get access to the cluster?) How can I access the same cache data across multiple computers? Sorry, I'm abit frustrated that the examples on the net only show 1 computer accessing the cache when multiple computers should be able to... thanks.
private void StartCache()
{
List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>(5);
servers.Add(new DataCacheServerEndpoint("Server1", 22233));
servers.Add(new DataCacheServerEndpoint("Server2", 22233));
DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration();
configuration.Servers = servers;
configuration.LocalCacheProperties = new DataCacheLocalCacheProperties();
DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off);
DataCacheFactory myCacheFactory = new DataCacheFactory(configuration);
_Cache = myCacheFactory.GetCache("default");
}
private void buttonSet_Click(object sender, EventArgs e)
{
_Cache.Put("MyKey", textBoxKey.Text);
}
private void buttonGet_Click(object sender, EventArgs e)
{
textBoxValue.Text = (string)_Cache.Get("MyKey");
}
<?xml version="1.0" encoding="utf-8" ?>
- <configuration>
- <configSections>
<section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
- <dataCache size="Medium">
- <caches>
- <cache type="partitioned" consistency="strong" name="default">
- <policy>
<eviction type="lru" />
<expiration defaultTTL="10" isExpirable="true" />
</policy>
</cache>
</caches>
- <hosts>
<host replicationPort="22236" arbitratorPort="22235" clusterPort="22234" hostId="1498625399" size="255" leadHost="true" account="SERVER1\Administrator" cacheHostName="AppFabricCachingService" name="Server1" cachePort="22233" />
<host replicationPort="22236" arbitratorPort="22235" clusterPort="22234" hostId="976875279" size="255" leadHost="true" account="SERVER2\Administrator" cacheHostName="AppFabricCachingService" name="Server2" cachePort="22233" />
</hosts>
</dataCache>
</configuration>
推荐答案
这很奇怪,它刚刚开始工作。我想知道,如果我的一位主持人倒下了?无论哪种方式,我都能够从另一台服务器访问一台服务器上的数据集。抱歉打扰了。
Well that's weird, it just started working. I wonder, if one of my hosts were down? Either way I'm able to access the data set on one server from the other. Sorry about the bother.
这篇关于无法从群集中的不同计算机访问缓存键/值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!