public bool Contains(string key) { Alachisoft.NCache.Web.Caching.Cache cache = (Alachisoft.NCache.Web.Caching.Cache)_caches[_primaryCache]; if (cache != null) { return(cache.Contains(key)); } else { return(false); } }
public bool Contains(string sessionId, string key) { Alachisoft.NCache.Web.Caching.Cache cache = null; object obj = null; GetCache(sessionId, key, out obj, "", "", out cache, false); if (cache != null) { return(cache.Contains(key)); } return(false); }
public OperationResult InitCache(string cacheID) { if (string.IsNullOrEmpty(cacheID)) ThrowInvalidArgumentsException(); OperationResult returnObject = new OperationResult(); try { _cache = Alachisoft.NCache.Web.Caching.NCache.InitializeCache(cacheID); if (!_cache.Contains(ItemVersionKey)) { _cache.Add(ItemVersionKey, ItemVersionValue); } returnObject = CreateReturnObject(Result.SUCCESS, null); } catch (Exception e) { ThrowCacheRuntimeException(e); } return returnObject; }
void GetCache(string sessionId, string key, out object value, string group, string subGroup, out Alachisoft.NCache.Web.Caching.Cache cache, bool isGet, ref LockHandle lockHandle, bool acquireLock) { value = null; //Implementation For Raiynair cookieless robots string sidPrefix = string.Empty; sidPrefix = sessionId.Substring(0, 4); if (!_settings.PrimaryCache.Contains(sidPrefix) && _isSessionCookieless) { _isSessionCookieless = false; cache = null; return; } _isSessionCookieless = false; cache = _caches[GetCache(sessionId)] as Alachisoft.NCache.Web.Caching.Cache; if (cache != null) { if (isGet) { value = cache.Get(key, Alachisoft.NCache.Web.Caching.Cache.NoLockExpiration, ref lockHandle, acquireLock); } } else { if (_currentSessionCache == null || _currentSessionCache == string.Empty) { IDictionaryEnumerator cacheDic = _caches.GetEnumerator(); do { /// This code will ensure that primary cache is used first to be lookedin. if (cache == null) { cache = _caches[_primaryCache] as Alachisoft.NCache.Web.Caching.Cache; } else { cache = (Alachisoft.NCache.Web.Caching.Cache)cacheDic.Value;// select the cache from enumerator. // primary cache is already traversed so no need to do it again. if (cache.ToString().Equals(_primaryCache)) { continue; } } if (isGet) { value = cache.Get(key, Alachisoft.NCache.Web.Caching.Cache.NoLockExpiration, ref lockHandle, acquireLock); } else { if (cache.Contains(key)) { value = new object(); break; } } } while (cacheDic.MoveNext() && value == null); if (value != null) // value was found from one of the caches. so use that cache for all further operations during this HTTP request. { _currentSessionCache = cache.ToString(); } else// value wasn't found from any of the caches. thus use hte primary cache for all further operations. { _currentSessionCache = _primaryCache; } } else { cache = _caches[_currentSessionCache] as Alachisoft.NCache.Web.Caching.Cache; if (isGet) { value = cache.Get(key, Alachisoft.NCache.Web.Caching.Cache.NoLockExpiration, ref lockHandle, acquireLock); } } } }
public bool Contains(string sessionId, string key) { return(_cache.Contains(key)); }