Пример #1
0
        public override void OnSuccess(MethodExecutionArgs eventArgs)
        {
            string key   = eventArgs.MethodExecutionTag as string;
            string group = GetGroupName(eventArgs.Method);

            if (key == null)
            {
                return;
            }
            object returnValue = eventArgs.ReturnValue;

            if (returnValue != null)
            {
                if (m_Expiration == ExpirationType.AbsoluteTime)
                {
                    CacheFactory.GetInstance(CacheName).Set(key, returnValue, DateTime.Now.Add(m_ExpireTime), group);
                }
                else if (m_Expiration == ExpirationType.SlidingTime)
                {
                    CacheFactory.GetInstance(CacheName).Set(key, returnValue, m_ExpireTime, group);
                }
                else
                {
                    CacheFactory.GetInstance(CacheName).Set(key, returnValue, group);
                }
            }
            CacheStatisticManager.NotHit(eventArgs.Method, CacheName, group);
        }
Пример #2
0
        public override void OnEntry(MethodExecutionArgs eventArgs)
        {
            string key   = CacheKeyGenerator.GenerateKeyName(eventArgs.Method, eventArgs.Arguments.ToArray(), m_Keys);
            object value = key != null?CacheFactory.GetInstance(CacheName).Get(key) : null;

            if (value == null)
            {
                eventArgs.MethodExecutionTag = key;
            }
            else
            {
                eventArgs.ReturnValue  = value;
                eventArgs.FlowBehavior = FlowBehavior.Return;
                CacheStatisticManager.Hit(eventArgs.Method, CacheName, GetGroupName(eventArgs.Method));
            }
        }