public void InitializeCache(string cache) { CacheConnectionOptions cacheConnectionOptions = new CacheConnectionOptions(); cacheConnectionOptions.AppName = FeatureUsageCollector.FeatureTag + FeatureEnum.aspnet_session; _cache = CacheManager.GetCache(cache, cacheConnectionOptions); }
internal DataCache(string cacheName, DataCacheFactoryConfiguration cacheConfiguration, bool expirable, TimeSpan defaultTTL) { if (string.IsNullOrWhiteSpace(cacheName)) { throw new ArgumentNullException(nameof(cacheName), "Value cannot be null"); } if (cacheConfiguration == null) { _cacheHandler = new CacheHandler(cacheName, null, expirable, defaultTTL); } else { CacheConnectionOptions connectionOptions = new CacheConnectionOptions { ConnectionTimeout = cacheConfiguration.ChannelOpenTimeout, ClientRequestTimeOut = cacheConfiguration.RequestTimeout }; if (cacheConfiguration.Servers != null && cacheConfiguration.Servers.Count() > 0) { var serverList = new List <ServerInfo>(cacheConfiguration.Servers.Count()); foreach (var server in cacheConfiguration.Servers) { serverList.Add(new ServerInfo(server.HostName, server.CachePort)); } connectionOptions.ServerList = serverList; } _cacheHandler = new CacheHandler(cacheName, connectionOptions, expirable, defaultTTL); } }
private CacheHandler InitiliazeCache(string cacheName, CacheConnectionOptions cacheConnectionOptions) { CacheHandler cache = new CacheHandler(); cache.InitializeCache(cacheName, cacheConnectionOptions); return(cache); }
private CacheBase InitiliazeCache(string cacheName, CacheConnectionOptions cacheConnectionOptions) { CacheBase cache = new CacheBase(); cache.InitializeCache(cacheName, cacheConnectionOptions); return(cache); }
public bool Load() { reloadTimer.Stop(); bool loaded = true; try { CacheConnectionOptions cacheConnectionOptions = new CacheConnectionOptions(); cacheConnectionOptions.AppName = cacheConnectionOptions.AppName = FeatureUsageCollector.FeatureTag + FeatureEnum.view_state; cache = CacheManager.GetCache(cacheName, cacheConnectionOptions); } catch (Exception ex) { loaded = false; FileBasedTraceProvider.Current.WriteTrace(TraceSeverity.Exception, "Could not initialize cache due to exception: {0}", ex.Message); } Loaded = loaded; if (!loaded) { ScheduleReload(); } return(loaded); }
public void ClearCache(string cacheId, bool forceClear) { ICache cache = null; try { CacheConnectionOptions cacheParams = new CacheConnectionOptions(); cache = CacheManager.GetCache(cacheId.ToLower(), cacheParams); if (!ForceClear) { long count = cache.Count; OutputProvider.WriteLine(""); OutputProvider.WriteLine("\"" + cacheId + "\" cache currently has " + count + " items. "); OutputProvider.WriteLine("Do you really want to clear it (Y or N)? "); string response = string.Empty; if (isPowershell) { ICollection <PSObject> resp = this.InvokeCommand.InvokeScript("Read-Host"); foreach (PSObject r in resp) { response = r.ToString(); } } else { response = Console.ReadLine(); } if (response != "Y" && response != "y") { OutputProvider.WriteLine(""); OutputProvider.WriteLine("Cache not cleared."); return; } } cache.Clear(); OutputProvider.WriteLine(""); OutputProvider.WriteLine("Cache cleared."); } catch (Exception e) { OutputProvider.WriteLine("Error: " + e.Message); OutputProvider.WriteErrorLine(e.ToString()); } finally { if (cache != null) { cache.Dispose(); } } }
public ConnectionMultiplexer(string cacheName, CacheConnectionOptions connectionOptions) { if (!CacheConnections.ContainsKey(cacheName.ToLower())) { var cache = CacheManager.GetCache(cacheName, connectionOptions); CacheConnections.Add(cacheName.ToLower(), cache); } _cache = CacheConnections[cacheName]; }
public CacheHandler(string cacheName, bool exceptionEnabled) { CacheConnectionOptions cacheConnectionOptions = new CacheConnectionOptions { AppName = FeatureUsageCollector.FeatureTag + FeatureEnum.hibernate }; _cache = Alachisoft.NCache.Client.CacheManager.GetCache(cacheName, cacheConnectionOptions); _refCount++; }
internal static Alachisoft.NCache.Client.ICache CreateCache( string cacheId, CacheConnectionOptions options) { if (options == null) { return(CacheManager.GetCache(cacheId)); } return(CacheManager.GetCache(cacheId, options)); }
public void DumpCacheKeys() { try { if (!ValidateParameters()) { return; } CacheConnectionOptions cacheParams = new CacheConnectionOptions(); ICache cache = CacheManager.GetCache(Name.ToLower(), cacheParams); //cache.ExceptionsEnabled = true; OutputProvider.WriteLine("Cache count: " + cache.Count); IDictionaryEnumerator keys = (IDictionaryEnumerator)cache.GetEnumerator(); if (keys != null) { long index = 0; bool checkFilter = (KeyFilter != ""); KeyFilter = KeyFilter.Trim(); while (keys.MoveNext()) { if ((KeyCount > 0) && (index >= KeyCount)) { break; } if (checkFilter == true) { string tmpKey = (string)keys.Key; if (tmpKey.Contains(KeyFilter) == true) { OutputProvider.WriteLine(tmpKey); } } else { OutputProvider.WriteLine(keys.Key); } index++; } //end while } //end if cache.Dispose(); } //end try block catch (Exception e) { OutputProvider.WriteErrorLine("Error: " + e.Message); OutputProvider.WriteErrorLine(e.ToString()); } OutputProvider.WriteLine(Environment.NewLine); }
public static IHealthChecksBuilder AddNCacheHealthCheck( this IHealthChecksBuilder builder, string cacheID, string name, HealthStatus?failureStatus = HealthStatus.Unhealthy, IEnumerable <string> tags = null, CacheConnectionOptions cacheConnectionOptions = null) { return(builder.Add(new HealthCheckRegistration( name ?? NAME, sp => new NCacheHealthCheck(cacheID, cacheConnectionOptions), failureStatus, tags))); }
// initialie a cache with respective options public ICache InitializeCache(string cacheName, CacheConnectionOptions cacheConnectionOptions = null) { if (string.IsNullOrEmpty(cacheName)) { throw new ArgumentNullException("Cache Name is empty."); } try { cache = CacheManager.GetCache(cacheName, cacheConnectionOptions); } catch { throw; } return(cache); }
public void StartTasks() { try { Thread[] threads = new Thread[_threadCount]; CacheConnectionOptions parameters = new CacheConnectionOptions(); parameters = ToolsUtil.AddServersInCacheConnectionOptions(_servers, parameters); _cache = CacheManager.GetCache(_cacheId, parameters); string pid = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); for (int threadIndex = 0; threadIndex < _threadCount; threadIndex++) { StressThreadTask threadTask = new StressThreadTask(_cache, _totalLoopCount, _testCaseIterations, _testCaseIterationDelay, _getsPerIteration, _updatesPerIteration, _dataSize, _expiration, _threadCount, _reportingInterval, threadIndex, _outputProvider, _adapter); _tasks.Add(threadTask); threadTask.Start(); } _adapter.Listen(); } catch (Exception) { throw; } }
public static IDataProtectionBuilder PersistKeysToNCache( this IDataProtectionBuilder builder, string cacheID, CacheConnectionOptions cachingOptions = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (cacheID == null) { throw new ArgumentNullException(nameof(cacheID)); } var repository = new NCacheXmlRepository(cacheID, cachingOptions); builder.Services.Configure <KeyManagementOptions>(options => { options.XmlRepository = repository; }); return(builder); }
public NCacheHealthCheck(string cacheID, CacheConnectionOptions cacheConnectionOptions = null) { _cacheID = cacheID ?? throw new ArgumentNullException(nameof(cacheID)); _cacheConnectionOptions = cacheConnectionOptions; }
public static ConnectionMultiplexer Connect(string cacheName, CacheConnectionOptions connectionOptions) { return(new ConnectionMultiplexer(cacheName, connectionOptions)); }
private void CheckAndInitializeCache() { if (_cache == null) { try { CacheConnectionOptions cacheInitParams = new CacheConnectionOptions(); if (_options.Value.ServerList != null) { cacheInitParams.ServerList = _options.Value.ServerList; } if (!string.IsNullOrEmpty(_options.Value.BindIP)) { cacheInitParams.ClientBindIP = _options.Value.BindIP; } if (_options.Value.Mode != null) { cacheInitParams.Mode = _options.Value.Mode; } if (_options.Value.LoadBalance != null) { cacheInitParams.LoadBalance = (bool)_options.Value.LoadBalance; } if (_options.Value.ClientRequestTimeOut != null) { cacheInitParams.ClientRequestTimeOut = _options.Value.ClientRequestTimeOut; } if (_options.Value.ConnectionTimeout != null) { cacheInitParams.ConnectionTimeout = _options.Value.ConnectionTimeout; } if (_options.Value.RetryInterval != null) { cacheInitParams.RetryInterval = _options.Value.RetryInterval; } if (_options.Value.RetryConnectionDelay != null) { cacheInitParams.RetryConnectionDelay = _options.Value.RetryConnectionDelay; } if (!string.IsNullOrEmpty(_options.Value.AppName)) { cacheInitParams.AppName = _options.Value.AppName; } if (_options.Value.RequestTimeout != null) { cacheInitParams.ClientRequestTimeOut = _options.Value.RequestTimeout; } _cache = CacheManager.GetCache(_cacheName, cacheInitParams); LogDebug("Cache " + _cache + " has been initialized. "); } catch (Exception ex) { _cache = null; LogError(ex); } } }
public Mapper(string cacheName, CacheConnectionOptions cacheConnectionOptions) { cache = CacheManager.GetCache(cacheName, cacheConnectionOptions); }
public NCacheXmlRepository(string cacheID, CacheConnectionOptions options = null) { _cacheID = cacheID; _options = options; }
public static CacheConnectionOptions AddServersInCacheConnectionOptions(string server, CacheConnectionOptions options) { if (!String.IsNullOrEmpty(server)) { ServerInfo[] cacheServers; string[] servers = server.Split(new char[] { ',' }); if (servers.Length > 0) { cacheServers = new ServerInfo[servers.Length]; for (int i = 0; i < cacheServers.Length; i++) { ServerInfo serverinfo = new ServerInfo(servers[i], 9800); cacheServers[i] = serverinfo; } options.ServerList = cacheServers; } } return(options); }