Пример #1
0
        public void Set(string key, CachedRequest val)
        {
            if (Interlocked.Increment(ref memoryPressureCounterOnSet) % 25 == 0) // check every 25 sets
            {
                TryClearMemory();
            }
            int lastWrite;

            if (lastWritePerDb.TryGetValue(val.Database, out lastWrite))
            {
                val.ReadTime = lastWrite;
            }
            actualCache.AddOrUpdate(key, val, (s, o) => val);
            lruKeys.Push(key);
        }
Пример #2
0
        /// <summary>
        /// Register the action as associated with the sender
        /// </summary>
        public void RecordAction(object sender, RequestResultArgs requestResultArgs)
        {
            var profilingInformationHolder = sender as IHoldProfilingInformation;

            if (profilingInformationHolder == null)
            {
                return;
            }


            profilingInformationHolder.ProfilingInformation.Requests =
                new List <RequestResultArgs>(profilingInformationHolder.ProfilingInformation.Requests)
            {
                requestResultArgs
            };

            leastRecentlyUsedCache.Push(profilingInformationHolder.ProfilingInformation);
        }