コード例 #1
0
        public static RequestCacheService GetCurrent()
        {
            if (HttpContext.Current == null)
            {
                return(new RequestCacheService());
            }
            RequestCacheService current = HttpContext.Current.Items [RequestCacheServiceName] as RequestCacheService;

            if (current == null)
            {
                current = new RequestCacheService();
                HttpContext.Current.Items.Add(RequestCacheServiceName, current);
            }
            return(current);
        }
コード例 #2
0
ファイル: DataProvider.cs プロジェクト: lusionx/lusionkit
        /// <summary>
        /// 从缓存里通过模式匹配移出数据
        /// </summary>
        public void RemoveByPattern()
        {
            if (enableLogCacheActivity)
            {
                System.Diagnostics.Trace.WriteLine("Cache Removed(RemoveByPattern()):" + cacheKey, "Cache");
                FileHelper.Log(cacheActivityLogPath, "Cache Removed(RemoveByPattern()):" + cacheKey);
            }

            //LJBinsTree binTree = CachedKeyDictionary[configKey] as LJBinsTree;
            //if (binTree != null)
            //{
            //    lock (binTree)
            //    {
            //        LJTreeNode treeNode = binTree.FindNode(new CacheBinInfo(Delimiter, cacheKey), binTree.GetRoot());
            //        if (treeNode != null)
            //        {
            //            RemoveCacheBinNode(binTree, treeNode);
            //        }
            //    }
            //}
            //else
            //{
            //    //CachingService.Current.RemoveByPattern(cacheKey);
            //    CachingService.Current.Remove(cacheKey);
            //}

            //统一处理
            //CachingService.Current.RemoveByPattern(cacheKey);
            object o = RequestCacheService.GetCurrent().Get(RemoveByPatternKey);

            if (o == null)
            {
                RequestCacheService.GetCurrent().Add(RemoveByPatternKey, cacheKey);
            }
            else
            {
                o += "|" + cacheKey;
                RequestCacheService.GetCurrent().Add(RemoveByPatternKey, o);
            }
        }