コード例 #1
0
ファイル: Cache.cs プロジェクト: Melikos-Com/TestSetENG
 public static void RemoveItem(String CacheKeyName)
 {
     //
     if (cache.Contains(CacheKeyName))
     {
         cache.Remove(CacheKeyName);
     }
 }
コード例 #2
0
        /// <summary>
        /// Xóa ip action cache
        /// </summary>
        /// <param name="action">truyền vào tên action</param>
        /// <returns></returns>
        public static void IpActionDelete(string action)
        {
            string ip = IPAddressHelper.GetClientIP();

            System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default;
            cache.Remove("P" + ip.ToLower() + "_" + action);
        }
コード例 #3
0
        public ActionResult SubmitVideoComment(hypster_tv_DAL.videoComment p_comment, string video_guid)
        {
            hypster_tv_DAL.Hypster_Entities hyDB          = new hypster_tv_DAL.Hypster_Entities();
            hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement();



            p_comment.comment = System.Text.RegularExpressions.Regex.Replace(p_comment.comment, @"<(.|\n)*?>", string.Empty);

            p_comment.ipAddress = IpAddress();
            p_comment.status    = (int)hypster_tv_DAL.newsCommentStatus.NoActive;
            p_comment.user_ID   = memberManager.getMemberByUserName(User.Identity.Name).id;
            p_comment.userName  = User.Identity.Name;
            p_comment.postDate  = DateTime.Now;


            hyDB.videoComments.AddObject(p_comment);
            hyDB.SaveChanges();



            //need to reset data cache (if exist)
            // this will allow to show new comment
            System.Runtime.Caching.ObjectCache i_chache = System.Runtime.Caching.MemoryCache.Default;
            if (i_chache["VideoComment_For_Tv_" + p_comment.videoClip_ID] != null)
            {
                i_chache.Remove("VideoComment_For_Tv_" + p_comment.videoClip_ID);
            }



            return(RedirectToAction("getVideo", "video", new { @video_id = video_guid }));
        }
コード例 #4
0
        public bool Remove(string key)
        {
            Ensure.StringArgumentNotNullAndNotEmpty(key, nameof(key));

            object removedValue = cache.Remove(key);

            return(removedValue != null);
        }
コード例 #5
0
        public void Limpiar()
        {
            List <string> nombres = cache.Select(kvp => kvp.Key).ToList();

            foreach (string nombre in nombres)
            {
                cache.Remove(nombre);
            }
            log.Info("Cache reiniciada!");
        }
コード例 #6
0
        /// <summary>
        /// 移除Cache
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="key"></param>
        public static void RemoveStore(this System.Runtime.Caching.ObjectCache cache,
                                       string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return;
            }

            lock (cache)
            {
                if (cache.Contains(key))
                {
                    cache.Remove(key);
                }
            }
        }
コード例 #7
0
ファイル: StorageManager.cs プロジェクト: kf6kjg/WHIP-LRU
        /// <summary>
        /// Stores the asset.  Mainly just a wrapper for the assetWriter PutAssetSync method.
        /// </summary>
        /// <param name="asset">Asset.</param>
        /// <param name="resultCallback">Result callback.</param>
        public void StoreAsset(StratusAsset asset, StorageResultCallback resultCallback)
        {
            asset          = asset ?? throw new ArgumentNullException(nameof(asset));
            resultCallback = resultCallback ?? throw new ArgumentNullException(nameof(resultCallback));

            if (asset.Id == Guid.Empty)
            {
                throw new ArgumentException("Asset cannot have zero ID.", nameof(asset));
            }

            PutResult result;

            try {
                _assetWriter.PutAssetSync(asset);
                result = PutResult.DONE;
            }
            catch (AssetExistsException) {
                result = PutResult.DUPLICATE;
            }
            catch (Exception e) {
                LOG.Error("Error storing asset.", e);
                result = PutResult.FAILURE;
            }

            if (result == PutResult.DONE)
            {
                // Clear negative cache entry.
                if (_negativeCache != null)
                {
                    _negativeCacheLock.EnterWriteLock();
                    try {
                        _negativeCache.Remove(asset.Id.ToString("N"));
                    }
                    finally {
                        _negativeCacheLock.ExitWriteLock();
                    }
                }
            }

            resultCallback(result);
        }
コード例 #8
0
        /// <summary>
        /// Permite asignar el valor del token guardado en Caché en null para que en el próximo Request vuelva a ser consultado mediante la autenticacion de Azure.
        /// Esto es en un caso eventual en que el Token sea revocado o expirado de forma extraordinaria, pues el cache dura 50 minutos, y la vida del token es de 60
        /// por lo que no debería ocurrir, pero si ocurre, se consultará el token en el próximo request.
        /// </summary>
        /// <param name="statusCode"></param>
        internal void RemoveCacheIfStatusIsUnauthorized(HttpStatusCode statusCode)
        {
            try
            {
                if (statusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default;

                    if (cache != null)
                    {
                        if (cache.Get("AuthToken") != null)
                        {
                            cache.Remove("AuthToken");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #9
0
 public void Clear(String key)
 {
     innerCache.Remove(key, null);
 }
コード例 #10
0
 /// <summary>
 /// Xóa Account action cache
 /// </summary>
 /// <param name="action">truyền vào tên action</param>
 /// <returns></returns>
 public static void AccountActionDelete(string accountName, string action)
 {
     System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default;
     cache.Remove("P" + accountName + "_" + action);
 }