Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Este post mostra como configurar o acesso ao cache do "Velocity" via código. Esse trecho, com pequenas alterações que eu fiz, foi extraído de um dos Samples do CTP2.
Antes de apresentar o código, segue definições das classes usadas nesse código.
ServerEndPoint: Classe que especifica um cache host na aplicação cliente.
CacheFactory: Classe que manipula os objetos de cache no cliente que fazem referência a um named cache (no servidor).
private void prepareClient()
{
CacheFactory myCacheFactory;
//-------------------------
// Configure Cache Client
//-------------------------
//Define Array for 1 Cache Host
System.Data.Caching.ServerEndPoint[] servers = new ServerEndPoint[1];
//Specify Cache Host Details
// Parameter 1 = host name
// Parameter 2 = cache port number
// Parameter 3 = cache service name
servers[0] = new ServerEndPoint("Servidor", 22233, "DistributedCacheService");
//Select Routing or Simple Client
// False = Simple Client (no routing table)
// True = Routing Client
bool routingClient = false;
//Select local cache if desired
// True = Enable local cache
// False = Disable local cache
bool localCache = true;
//Disable exception messages since this sample works on a cache aside
System.Data.Caching.CacheFactory.DisableLogSinks();
//Pass configuration settings to cacheFactory constructor
myCacheFactory = new CacheFactory(servers, routingClient, localCache);
//Get reference to named cache called "NamedCache1"
myDefaultCache = myCacheFactory.GetCache("default");
}
Abraços,
Daibert
Comments
- Anonymous
December 29, 2008
PingBack from http://www.codedstyle.com/configurando-acesso-ao-cache-via-codigo/