Ejemplo n.º 1
0
        /// <summary>
        /// 清除
        /// </summary>
        /// <param name="strKey"></param>
        public static void RemoveMemcached(string strKey)
        {
            SlMemCached memCached = MemcachedTool.InitMemcachedClient();

            if (memCached.KeyExists(strKey))
            {
                memCached.Delete(strKey);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strKey"></param>
        /// <returns></returns>
        public static T GetMemcached <T>(string strKey)
        {
            SlMemCached memCached = MemcachedTool.InitMemcachedClient();

            if (memCached.KeyExists(strKey))
            {
                return(memCached.Get <T>(strKey));
            }
            return(default(T));
        }
Ejemplo n.º 3
0
        public static void RemoveAllMemcached(List <string> lstKey)
        {
            SlMemCached memCached = MemcachedTool.InitMemcachedClient();

            for (int i = 0, iLength = lstKey.Count; i < iLength; i++)
            {
                if (memCached.KeyExists(lstKey[i]))
                {
                    memCached.Delete(lstKey[i]);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="objSource"></param>
        /// <param name="seconds"></param>
        public static void SetMemcached(string strKey, object objSource, double seconds = 43200)
        {
            SlMemCached memCached = MemcachedTool.InitMemcachedClient();

            memCached.Set(strKey, objSource, DateTime.Now.AddSeconds(seconds));
        }