示例#1
0
文件: Cache.cs 项目: FlyLikeOpen/Fly
 public static IDictionary <string, T> GetDistributedCache <T>(IEnumerable <string> cacheKeyList)
 {
     if (cacheKeyList == null || cacheKeyList.Count() <= 0)
     {
         return(new Dictionary <string, T>(0));
     }
     return(MemcachedCacheHelper.Get <T>(cacheKeyList.ToArray()));
 }
示例#2
0
文件: Cache.cs 项目: FlyLikeOpen/Fly
        public static T GetWithDistributedCache <T>(string cacheKey, Func <T> getter, bool absoluteExpiration = true, int cacheExpirationMinutes = 30, string groupName = null)
        {
            bool   found;
            object t = MemcachedCacheHelper.Get(cacheKey, out found);

            if (found)
            {
                return((T)t);
            }
            T data = getter();

            if (absoluteExpiration)
            {
                MemcachedCacheHelper.Set(cacheKey, data, DateTime.Now.AddMinutes(cacheExpirationMinutes), groupName);
            }
            else
            {
                MemcachedCacheHelper.Set(cacheKey, data, TimeSpan.FromMinutes(cacheExpirationMinutes), groupName);
            }
            return(data);
        }
示例#3
0
文件: Cache.cs 项目: FlyLikeOpen/Fly
 public static T GetDistributedCache <T>(string cacheKey, out bool found)
 {
     return(MemcachedCacheHelper.Get <T>(cacheKey, out found));
 }
示例#4
0
文件: Cache.cs 项目: FlyLikeOpen/Fly
 public static T GetDistributedCache <T>(string cacheKey)
 {
     return(MemcachedCacheHelper.Get <T>(cacheKey));
 }