/// <summary> /// 创建redis对象 /// </summary> /// <returns></returns> public CacheClient CreateInstance() { CacheClient client = null;//获取Redis操作接口 if (IsTrue) { switch (IsCacheName) { case CacheEnum.RedisCache: client = new RedisCacheClient((DBEnum)RedisDB); break; case CacheEnum.MemCache: client = new MemCacheClient(); break; case CacheEnum.LocalCache: client = new LocalClient(); break; } } else { cacheLog.Info(IsCacheName.ToString() + "缓存未启用"); } return(client); }
public void TestNullKeyGet() { ICache cache = new MemCacheClient(); cache.Put("nunit", "value"); Thread.Sleep(1000); object item = cache.Get(null); Assert.IsNull(item); }
private BuffPoolCore() { try { s_buffSync = BuffSyncThreadProvider.Instance(); s_memBuffPool = new MemCacheClient(MEMPrefixBuffPool, MEMTickSecondsBuffPool); this.InitFlag = true; } catch (Exception ex) { LogHelper.Insert(ex, "BuffPoolCore:Init"); this.InitFlag = false; } }
/// <summary> /// 获取刚发布的公文 /// </summary> /// <returns></returns> public List <V_SystemNotice> RefreshSendDocData(string employeeid, int pageIndex , int pageSize, ref int pageCount, ref int DataCount, List <string> postIDs , List <string> companyIDs, List <string> departmentIDs , ref bool NeedGetNewData, bool NeedAllData , string filterString, List <object> paras, string Doctitle) { if (NeedAllData)//强制获取所有数据 { NeedGetNewData = true; } else { //否则通过读取缓存判断是否需要获取更新数据,否的话直接返回null; try { var obj = MemCacheClient.Get(employeeid + "SendDocMent"); if (obj == null) { NeedGetNewData = false; return(null); } else { //Tracer.Debug("从MemCached获取到新的公司发文数据,Key" + employeeid + "SendDocMent"); NeedGetNewData = true; MemCacheClient.Remove(employeeid + "SendDocMent"); } } catch (Exception ex) { Tracer.Debug("公司发文获取缓存对象失败:" + ex.ToString()); } } try { //Tracer.Debug("公司发文中查询的内容:" + Doctitle ); IQueryable <V_SystemNotice> ent = GetHouseAndNoticeInfoToMobile(pageIndex, pageSize, ref pageCount, ref DataCount, employeeid , postIDs, companyIDs, departmentIDs, filterString, paras, Doctitle); return(ent != null?ent.ToList() : null); } catch (Exception ex) { Tracer.Debug("房源管理HouseInfoManagerBll-GetHouseAndNoticeInfo" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(null); } }
private ArenaBuffDataCore() { try { s_buffSync = ArenaBuffSyncThreadProvider.Instance(); if (ShareUtil.IsCross) { s_memBuffMember = new MemCacheClient(MEMPrefixBuffMember, 30); } else { s_memBuffMember = new MemCacheClient(MEMPrefixBuffMember, MEMTickSecondsBuffMember); } this.InitFlag = true; } catch (Exception ex) { SystemlogMgr.Error("BuffDataCore:Init", ex); this.InitFlag = false; } }
public void TestNoPropertiesConstructor() { ICache cache = new MemCacheClient("nunit"); Assert.IsNotNull(cache); }
public void TestEmptyProperties() { ICache cache = new MemCacheClient("nunit", new Dictionary<string, string>()); Assert.IsNotNull(cache); }
public void TestDefaultConstructor() { ICache cache = new MemCacheClient(); Assert.IsNotNull(cache); }
public void TestNullValuePut() { ICache cache = new MemCacheClient(); Assert.Throws<ArgumentNullException>(() => cache.Put("nunit", null)); }
public void TestNullKeyRemove() { ICache cache = new MemCacheClient(); Assert.Throws<ArgumentNullException>(() => cache.Remove(null)); }
public void TestNullKeyPut() { ICache cache = new MemCacheClient(); Assert.Throws <ArgumentNullException>(() => cache.Put(null, null)); }
public void TestEmptyProperties() { ICache cache = new MemCacheClient("nunit", new Dictionary <string, string>()); Assert.IsNotNull(cache); }
public void TestNullValuePut() { ICache cache = new MemCacheClient(); Assert.Throws <ArgumentNullException>(() => cache.Put("nunit", null)); }