Domanda

I am trying to understand how to properly configure AppFabric Caching on a web site. We are planning to use SQL Server as the cache manager and as far as I can understand the SQL will contain a list of the cache hosts in the cluster.

However, when running

DataCacheFactory factory = new DataCacheFactory();

I get

Server collection cannot be empty.

which, I guess, is to be expected since I have not added any servers in the web.config.

However, I do not want to maintain a server list on each web server, I want that to be done centrally on the SQL Server. I assume there is a way to point to the SQL Server, but I cannot find information on how to do this.

(I have also tried with the XML configration option, but it cannot even find that file. I have checked the health of the service in power shell.)

How do I centralize the server cache host list?

È stato utile?

Soluzione

We are planning to use SQL Server as the cache manager and as far as I can understand the SQL will contain a list of the cache hosts in the cluster.

It's false. SQL Server can perform cluster management but it's only for managing the cache hosts, and ultimately, the cache cluster. It's just for internal management and your clients can use this configuration and they don't need to have acces to Sql Server.

DataCacheFactory factory = new DataCacheFactory();

This code will try to load default datacacheclient in config. In your case, it should be empty that's why you get this error.

You can still use code to configure cache host in this way.

// Declare array for cache host(s).
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
servers[0] = new DataCacheServerEndpoint("CacheServer1", 22233);
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
factoryConfig.Servers = servers;
DataCacheFactory mycacheFactory = new DataCacheFactory(factoryConfig);
DataCache myDefaultCache = mycacheFactory.GetCache("NamedCache1");

You don't need to specify all host names here, because AppFabric Caching will route request to the correct cache host, event if it is not in your list.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top