/// <summary> /// 使用set方式增加/更新缓存 /// </summary> /// <param name="strKey">关键字</param> /// <param name="objValue">值</param> /// <param name="lNumofSeconds">过期时间,单位秒</param> /// <param name="cacheType">缓存类型,0=memcached,1=redis</param> /// <returns></returns> public static bool Set(string strKey, object objValue, long lNumofSeconds, int cacheType = 1) { if (cacheType == 0) { return(DistCache.Set(strKey, objValue, lNumofSeconds)); } else { return(RedisManager.Set <object>(strKey, objValue, lNumofSeconds)); } }
/// <summary> /// 使用set方式增加/更新缓存 /// </summary> /// <param name="strKey">关键字</param> /// <param name="objValue">值</param> /// <param name="isSetExpireTime">true:过期时间默认为配置节defaultExpireSeconds;false:永不过期</param> /// <param name="cacheType">缓存类型,0=memcached,1=redis</param> /// <returns></returns> //public static bool Set(string strKey, object objValue, bool isSetExpireTime = true, int cacheType = 1) //{ // if (cacheType == 0) // { // return DistCache.Set(strKey, objValue, isSetExpireTime); // } // else // { // return RedisManager.Set<object>(strKey, objValue, isSetExpireTime); // } //} public static bool Set <T>(string strKey, T objValue, bool isSetExpireTime = true, int cacheType = 1) { if (cacheType == 0) { return(DistCache.Set(strKey, objValue, isSetExpireTime)); } else { return(RedisManager.Set <T>(strKey, objValue, isSetExpireTime)); } }