// // GET: /Cache/ public ActionResult Index() { DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration(); DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1] { new DataCacheServerEndpoint(factoryConfig.Servers.First().HostName, 22233) }; factoryConfig.Servers = servers; DataCacheFactory mycacheFactory = new DataCacheFactory(factoryConfig); DataCache cache = mycacheFactory.GetCache("default"); var list = new List<CacheEntryViewModel>(); if (cache.Get("Time") == null) { cache.Put("Time", DateTime.Now); } list.Add(new CacheEntryViewModel() { Key= "Time", Value = ((DateTime)cache.Get("Time")).ToLongTimeString() }); return View(list); }
private DataCacheServerEndpoint[] GetClusterEndpoints() { DataCacheServerEndpoint[] cacheCluster = new DataCacheServerEndpoint[Servers.Length]; int i = 0; foreach (string server in Servers) { string[] s = server.Split(':'); string host = s[0]; int port = s.Length == 2 ? s[1].ToInt(22233) : 22233; cacheCluster[i] = new DataCacheServerEndpoint(host, port); i++; } return(cacheCluster); }
private void btnConnect_Click(object sender, EventArgs e) { if (myCache == null) { try { DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1]; servers[0] = new DataCacheServerEndpoint(txtCacheServer.Text, int.Parse(txtPort.Text)); DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration(); factoryConfig.Servers = servers; if (!(checkBoxSecurity.Checked)) { DataCacheSecurity security = new DataCacheSecurity(DataCacheSecurityMode.None, DataCacheProtectionLevel.None); factoryConfig.SecurityProperties = security; } //You must set the security authentication account type to DomainAccount on the client side //when the caching service identity is a domain account. The default type is SystemAccount. if (checkBoxDomainAcc.Checked) { factoryConfig.DataCacheServiceAccountType = DataCacheServiceAccountType.DomainAccount; } if (checkBoxLocalCache.Checked) { //TimeSpan localTimeout = new TimeSpan(0, 1, 0); TimeSpan localTimeout = TimeSpan.FromSeconds(Convert.ToDouble(txtTimeout.Text)); DataCacheLocalCacheProperties localCacheConfig = new DataCacheLocalCacheProperties(10000, localTimeout, DataCacheLocalCacheInvalidationPolicy.TimeoutBased); factoryConfig.LocalCacheProperties = localCacheConfig; } myCacheFactory = new DataCacheFactory(factoryConfig); myCache = myCacheFactory.GetCache(txtCacheName.Text); //this.Text = "AppFabric Test Client has connected to Cache Cluster..."; UpdateStatus("You have connected to the Cache Cluster."); lblConnectionStatus.Text = "CONNECTED"; } catch (Exception ex) { HandleException(ex); } } }