Beispiel #1
0
 public HomeController(ILogger <HomeController> logger, ILogoService logo, IBaseCache cache, RedisStringService stringService, IRabbitManage mq)
 {
     _Logger        = logger;
     _Logo          = logo;
     _BaseCache     = cache;
     _StringService = stringService;
     _RabbitMQ      = mq;
 }
        protected virtual T GetCache <T>(string name, object[] args) where T : IBaseCache
        {
            var        type  = typeof(T);
            IBaseCache cache = null;

            if (!cacheDic.TryGetValue(type, out cache))
            {
                cacheDic[type] = cache = IocUtils.Get <T>(name, args);
            }

            return((T)cache);
        }
Beispiel #3
0
        private static void GetCacheability(BaseCacheItem httpCacheabilityTypeItem, IBaseCache redirectAction)
        {
            var httpCacheabilityTypeTargetItem = httpCacheabilityTypeItem.HttpCacheability.TargetItem;
            HttpCacheability?httpCacheability  = null;

            if (httpCacheabilityTypeTargetItem != null)
            {
                switch (httpCacheabilityTypeTargetItem.ID.ToString())
                {
                case Constants.HttpCacheabilityType_NoCache_ItemId:
                    httpCacheability = HttpCacheability.NoCache;
                    break;

                case Constants.HttpCacheabilityType_Private_ItemId:
                    httpCacheability = HttpCacheability.Private;
                    break;

                case Constants.HttpCacheabilityType_Server_ItemId:
                    httpCacheability = HttpCacheability.Server;
                    break;

                case Constants.HttpCacheabilityType_ServerAndNoCache_ItemId:
                    httpCacheability = HttpCacheability.ServerAndNoCache;
                    break;

                case Constants.HttpCacheabilityType_Public_ItemId:
                    httpCacheability = HttpCacheability.Public;
                    break;

                case Constants.HttpCacheabilityType_ServerAndPrivate_ItemId:
                    httpCacheability = HttpCacheability.ServerAndPrivate;
                    break;

                default:
                    break;
                }
            }
            redirectAction.HttpCacheability = httpCacheability;
        }
Beispiel #4
0
 private static void GetCacheability(BaseCacheItem httpCacheabilityTypeItem, IBaseCache redirectAction)
 {
     var httpCacheabilityTypeTargetItem = httpCacheabilityTypeItem.HttpCacheability.TargetItem;
     HttpCacheability? httpCacheability = null;
     if (httpCacheabilityTypeTargetItem != null)
     {
         switch (httpCacheabilityTypeTargetItem.ID.ToString())
         {
             case Constants.HttpCacheabilityType_NoCache_ItemId:
                 httpCacheability = HttpCacheability.NoCache;
                 break;
             case Constants.HttpCacheabilityType_Private_ItemId:
                 httpCacheability = HttpCacheability.Private;
                 break;
             case Constants.HttpCacheabilityType_Server_ItemId:
                 httpCacheability = HttpCacheability.Server;
                 break;
             case Constants.HttpCacheabilityType_ServerAndNoCache_ItemId:
                 httpCacheability = HttpCacheability.ServerAndNoCache;
                 break;
             case Constants.HttpCacheabilityType_Public_ItemId:
                 httpCacheability = HttpCacheability.Public;
                 break;
             case Constants.HttpCacheabilityType_ServerAndPrivate_ItemId:
                 httpCacheability = HttpCacheability.ServerAndPrivate;
                 break;
             default:
                 break;
         }
     }
     redirectAction.HttpCacheability = httpCacheability;
 }
Beispiel #5
0
 protected async Task ClearCacheTokenAsync(IBaseCache cacheService)
 {
     await cacheService.RemoveObjectAsync(CacheConst.Token);
 }
Beispiel #6
0
 protected async Task SaveCacheTokenAsync(IBaseCache cacheService, string token)
 {
     await cacheService.UpdateObjectAsync(CacheConst.Token, token);
 }
Beispiel #7
0
        protected async Task <string> GetCacheTokenAsync(IBaseCache cacheService)
        {
            var token = await cacheService.GetObjectAsync <string>(CacheConst.Token);

            return(token);
        }
Beispiel #8
0
 /// <summary>
 /// 【异步方法】获取所有以key为前缀的缓存信息集合
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="baseCache"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static Task <IList <T> > GetAllByPrefixAsync <T>(this IBaseCache <T> baseCache, string key) where T : class, new()
 {
     return(baseCache.Cache.GetAllByPrefixAsync <T>(key));
 }
Beispiel #9
0
 /// <summary>
 /// 【异步方法】获取所有缓存信息集合
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="baseCache"></param>
 /// <returns></returns>
 public static Task <IDictionary <string, object> > GetAsync <T>(this IBaseCache <T> baseCache) where T : class, new()
 {
     return(baseCache.Cache.GetAllAsync());
 }
Beispiel #10
0
 /// <summary>
 /// 获取所有缓存集合
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="baseCache"></param>
 /// <returns></returns>
 public static IDictionary <string, object> GetAll <T>(this IBaseCache <T> baseCache) where T : class, new()
 {
     return(baseCache.Cache.GetAll());
 }
 public CustomersCacheManager(IBaseCache baseCache)
 {
     _baseCache = baseCache;
 }