예제 #1
0
 private void MyCachedItemRemovedCallback(CacheEntryRemovedArguments arguments)
 {
     if (this.RemovedEvent != null)
     {
         this.RemovedEvent(arguments);
     }
 }
예제 #2
0
 private void RemovedCallback(CacheEntryRemovedArguments arguments)
 {
     // Log these values from arguments list 
     String strLog = String.Concat("Reason: ", arguments.RemovedReason.ToString(), " | Key-Name: ",
         arguments.CacheItem.Key, " | Value-Object: ",
         arguments.CacheItem.Value.ToString());
 }
        private void RemovedCallback(CacheEntryRemovedArguments arguments)
        {
#if DEBUG
            String strLog = String.Concat("Reason: ", arguments.RemovedReason.ToString(), " | Key-Name: ", arguments.CacheItem.Key, " | Value-Object: ", arguments.CacheItem.Value.ToString());

            WebDavServer.Log.Info("Cache: " + name + " - " + strLog);
#endif
        }
 private void RemovedCallback(CacheEntryRemovedArguments arguments)
 {
     // if we are not removing the item cos it was removed by the caller then save it to disk
     if (arguments.RemovedReason == CacheEntryRemovedReason.Evicted || arguments.RemovedReason == CacheEntryRemovedReason.Expired)
     {
         if (CacheItemRemovedCallback != null)
             CacheItemRemovedCallback.Invoke(arguments.CacheItem.Key, arguments.CacheItem.Value);
        }
 }
예제 #5
0
        public void OnCacheEntryRemoved(CacheEntryRemovedArguments args)
        {
            Debug.WriteLine("Cache entry for '{0}' has been removed because of {1}.", args.CacheItem.Key, args.RemovedReason);

            if (OnEntryRemoved != null)
            {
                OnEntryRemoved(args.CacheItem.Key);
            }
        }
 private void CallCacheEntryRemovedCallback(MemoryCache cache, CacheEntryRemovedReason reason)
 {
     if (this._callback != null)
     {
         CacheEntryRemovedArguments arguments = new CacheEntryRemovedArguments(cache, reason, new CacheItem(base.Key, this._value));
         try
         {
             this._callback(arguments);
         }
         catch
         {
         }
     }
 }
 internal void CacheEntryRemovedCallback(CacheEntryRemovedArguments arguments) {
     string key = arguments.CacheItem.Key;
     object value = arguments.CacheItem.Value;
     CacheItemRemovedReason reason;
     switch (arguments.RemovedReason) {
         case CacheEntryRemovedReason.Removed :
             reason = CacheItemRemovedReason.Removed;
             break;
         case CacheEntryRemovedReason.Expired :
             reason = CacheItemRemovedReason.Expired;
             break;
         case CacheEntryRemovedReason.Evicted :
             reason = CacheItemRemovedReason.Underused;
             break;
         case CacheEntryRemovedReason.ChangeMonitorChanged :
             reason = CacheItemRemovedReason.DependencyChanged;
             break;
         default :
             reason = CacheItemRemovedReason.Removed;
             break;
     }
     _callback(key, value, reason);
 }
예제 #8
0
 private void OnRemoveCacheItem(CacheEntryRemovedArguments removed)
 {
     Console.WriteLine(removed.RemovedReason);
 }
예제 #9
0
 private void OnCacheEntryRemoved(CacheEntryRemovedArguments arg)
 {
     string key = arg.CacheItem.Key;
     CacheRemovedReason reason = CacheRemovedReason.None;
     switch (arg.RemovedReason)
     {
         case CacheEntryRemovedReason.Removed:
             reason = CacheRemovedReason.Removed;
             break;
         case CacheEntryRemovedReason.Expired:
             reason = CacheRemovedReason.Expired;
             break;
         case CacheEntryRemovedReason.ChangeMonitorChanged:
             reason = CacheRemovedReason.Changed;
             break;
         case CacheEntryRemovedReason.Evicted:
         case CacheEntryRemovedReason.CacheSpecificEviction:
             break;
         default:
             break;
     }
     this._callback.BeginInvoke(key, arg.CacheItem.Value, reason, null, null);
 }
예제 #10
0
        private static void CacheEntryRemoved(CacheEntryRemovedArguments arguments) {

        }
예제 #11
0
        private void CacheItemRemovedCallback(CacheEntryRemovedArguments arguments)
        {
            EventHandler<CacheItemRemovedEventArgs> expiredEvent = this.CacheItemExpired;

            if (expiredEvent != null)
            {
                CacheItemRemovedReason reason = CacheItemRemovedReason.Other;

                switch (arguments.RemovedReason)
                {
                    case CacheEntryRemovedReason.Expired:
                        reason = CacheItemRemovedReason.Expired;
                        break;
                    case CacheEntryRemovedReason.Removed:
                        reason = CacheItemRemovedReason.Removed;
                        break;
                    case CacheEntryRemovedReason.Evicted:
                    case CacheEntryRemovedReason.CacheSpecificEviction:
                        reason = CacheItemRemovedReason.Evicted;
                        break;
                }

                expiredEvent(this, new CacheItemRemovedEventArgs(arguments.CacheItem.Key, reason));
            }
        }
예제 #12
0
파일: MemoryCache.cs 프로젝트: Numpsy/mono
            internal static void OnCacheEntryRemovedCallback(CacheEntryRemovedArguments arguments) {
                MemoryCache cache = arguments.Source as MemoryCache;
                SentinelEntry entry = arguments.CacheItem.Value as SentinelEntry;
                CacheEntryRemovedReason reason = arguments.RemovedReason;
                switch (reason) {
                    case CacheEntryRemovedReason.Expired:
                        break;
                    case CacheEntryRemovedReason.ChangeMonitorChanged:
                        if (entry.ExpensiveObjectDependency.HasChanged) {
                            // If the expensiveObject has been removed explicitly by Cache.Remove,
                            // return from the SentinelEntry removed callback
                            // thus effectively removing the SentinelEntry from the cache.
                            return;
                        }
                        break;
                    case CacheEntryRemovedReason.Evicted:
                        Dbg.Fail("Reason should never be CacheEntryRemovedReason.Evicted since the entry was inserted as NotRemovable.");
                        return;
                    default:
                        // do nothing if reason is Removed or CacheSpecificEviction
                        return;
                }

                // invoke update callback
                try {
                    CacheEntryUpdateArguments args = new CacheEntryUpdateArguments(cache, reason, entry.Key, null);
                    entry.CacheEntryUpdateCallback(args);
                    Object expensiveObject = (args.UpdatedCacheItem != null) ? args.UpdatedCacheItem.Value : null;
                    CacheItemPolicy policy = args.UpdatedCacheItemPolicy;
                    // Dev10 861163 - Only update the "expensive" object if the user returns a new object,
                    // a policy with update callback, and the change monitors haven't changed.  (Inserting
                    // with change monitors that have already changed will cause recursion.)
                    if (expensiveObject != null && IsPolicyValid(policy)) {
                        cache.Set(entry.Key, expensiveObject, policy);
                    }
                    else {
                        cache.Remove(entry.Key);
                    }
                }
                catch {
                    cache.Remove(entry.Key);
                    // Review: What should we do with this exception?
                }
            }
예제 #13
0
		private void RootCacheItemRemoved(CacheEntryRemovedArguments arguments)
		{
			rootCacheKeyStored = false;
		}
 private void RemovedCallback(CacheEntryRemovedArguments arguments)
 {
     Console.WriteLine($"{DateTime.Now} - [Cache] {arguments.CacheItem.Key} expired. Removed from cache");
 }
예제 #15
0
 private void CacheEntryRemove(CacheEntryRemovedArguments arguments)
 {
     _log.Info("Tenant {0} payment cache is expired.", Convert.ToInt32(arguments.CacheItem.Key));
 }
 public void EntryRemovedCallBack(CacheEntryRemovedArguments arguments)
 {
     if ( arguments.CacheItem is OpenSearchResponseCacheItem ){
         OpenSearchResponseCacheItem item = new OpenSearchResponseCacheItem(arguments.CacheItem);
         log.DebugFormat("OpenSearch Cache [remove] reason {1} {0}", item.OpenSearchUrl, arguments.RemovedReason);
     }
 }
        private void CacheEntryRemovedCallback(CacheEntryRemovedArguments arguments)
        {
            lock (this.lockObject)
            {
                var requests = (List<IncompleteReferenceRequest>)arguments.CacheItem.Value;

                // dispose outstanding requests
                foreach (var request in requests)
                    if (!request.DontDispose)
                        request.Serializer.Dispose();
            }
        }
예제 #18
0
        /// <summary>
        /// Kills the process on removal from cache.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        private void KillOnRemoval(CacheEntryRemovedArguments arguments)
        {
            // Lets kill the process before removing it from our in-memory cache
            var process = arguments.CacheItem.Value as Process;

            try
            {
                if (process != null)
                {
                    process.Kill();
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
            }
        }
 /// <summary>
 /// Responds to cache items being removed from the underlying <see cref="MemoryCache"/>.
 /// </summary>
 /// <param name="e">Provides information about a cache entry that was removed from the cache.</param>
 private static void OnCacheItemRemoved(CacheEntryRemovedArguments e)
 {
     Log.Trace("Aggregate {0} was removed: {1}.", e.CacheItem.Key, e.RemovedReason);
 }
예제 #20
0
        /// <summary>
        /// Called when [removed].
        /// </summary>
        /// <param name="arguments">
        /// The arguments.
        /// </param>
        private void OnRemoved(CacheEntryRemovedArguments arguments)
        {
            IrcUser ircUser = arguments.CacheItem.Value as IrcUser;

            Trace.TraceInformation("User {0} was removed from cache", ircUser.NickName);
        }
예제 #21
0
 /// <summary>
 /// Information about a weather result removed from cache.
 /// </summary>
 /// <param name="arguments">
 /// The arguments.
 /// </param>
 private void RemovedCallback(CacheEntryRemovedArguments arguments)
 {
     Trace.TraceInformation("Removing weather request from cache: {0}", arguments.CacheItem.Key);
 }
예제 #22
0
 private void CacheEntryRemovedCallback(CacheEntryRemovedArguments arguments)
 {
     switch (arguments.RemovedReason)
     {
         case CacheEntryRemovedReason.Evicted:
         case CacheEntryRemovedReason.Expired:
             // free memory
             var serializer = (VowpalWabbitJsonSerializer)arguments.CacheItem.Value;
             serializer.Dispose();
                 
             this.perfCounters.Feature_Requests_Pending.IncrementBy(-1);
             this.perfCounters.Feature_Requests_Discarded.Increment();
             break;
     }
 }
예제 #23
0
 private void CacheEntryRemove(CacheEntryRemovedArguments arguments)
 {
     if (arguments.RemovedReason != CacheEntryRemovedReason.CacheSpecificEviction)
         _log.Info("Tenant {0} payment cache is expired.", Convert.ToInt32(arguments.CacheItem.Key));
 }
예제 #24
0
 private void ItemRemoved(CacheEntryRemovedArguments arguments)
 {
     if (_persistenceEngine != null)
         _persistenceEngine.Remove((CacheableEntity)(arguments.CacheItem.Value as CacheItem).Value);
 }
            internal static void OnCacheEntryRemovedCallback(CacheEntryRemovedArguments arguments)
            {
                MemoryCache source = arguments.Source as MemoryCache;
                MemoryCache.SentinelEntry entry = arguments.CacheItem.Value as MemoryCache.SentinelEntry;
                CacheEntryRemovedReason removedReason = arguments.RemovedReason;
                switch (removedReason)
                {
                    case CacheEntryRemovedReason.Expired:
                        goto Label_004B;

                    case CacheEntryRemovedReason.Evicted:
                        break;

                    case CacheEntryRemovedReason.ChangeMonitorChanged:
                        if (!entry.ExpensiveObjectDependency.HasChanged)
                        {
                            goto Label_004B;
                        }
                        break;

                    default:
                        return;
                }
                return;
            Label_004B:
                try
                {
                    CacheEntryUpdateArguments arguments2 = new CacheEntryUpdateArguments(source, removedReason, entry.Key, null);
                    entry.CacheEntryUpdateCallback(arguments2);
                    object obj2 = (arguments2.UpdatedCacheItem != null) ? arguments2.UpdatedCacheItem.Value : null;
                    CacheItemPolicy updatedCacheItemPolicy = arguments2.UpdatedCacheItemPolicy;
                    if ((obj2 != null) && IsPolicyValid(updatedCacheItemPolicy))
                    {
                        source.Set(entry.Key, obj2, updatedCacheItemPolicy, null);
                    }
                    else
                    {
                        source.Remove(entry.Key, null);
                    }
                }
                catch
                {
                    source.Remove(entry.Key, null);
                }
            }
        private void RootCacheItemRemovedCallback(CacheEntryRemovedArguments arguments)
	    {
            _isRootItemCached = false;
	    }
 /// <summary>
 /// Called by the underlying <see cref="Cache"/> collection when an item is removed.
 /// </summary
 /// <param name="args">Cache entry removed event arguments.</param>
 protected abstract void CacheEntryRemoved(CacheEntryRemovedArguments args);        
예제 #28
0
        private void CacheItemRemoved(CacheEntryRemovedArguments args)
        {
            byte[] command = null;
            using (var memoryStream = new MemoryStream())
            {
                memoryStream.Write("expire");
                memoryStream.Write(args.CacheItem.Key);
                command = memoryStream.ToArray();
            }

            // Notify all clients
            _server.Broadcast(command);
        }
 private void CallCacheEntryRemovedCallback(MemoryCache cache, CacheEntryRemovedReason reason) {
     if (_callback == null) {
         return;
     }
     CacheEntryRemovedArguments args = new CacheEntryRemovedArguments(cache, reason, new CacheItem(Key, _value));
     try {
         _callback(args);
     }
     catch {
         // 
     }
 }
 private static void DisposePolicyRemovedCallback(CacheEntryRemovedArguments arguments)
 {
     var value = arguments.CacheItem.Value as IDisposable;
     if (value != null)
     {
         value.Dispose();
     }
 }