Esempio n. 1
0
 /// <summary>
 /// 方法执行后,置入缓存
 /// </summary>
 /// <param name="args"></param>
 public override void OnSuccess(PostSharp.Aspects.MethodExecutionArgs args)
 {
     //当为Read模式时,只读取缓存数据,不进行写操作 .&& 当RemoveOnEntry操作时,删除缓存的操作只在OnEntry进行,退出OnSuccess.
     if (g_ActionType == ActionType.Read)
     {
         return;
     }
     try
     {
         string key = GetMethodKey(args, this);
         if (g_CacheSeconds > 0)
         {
             RedisService.Set <Object>(g_configName, key, args.ReturnValue, g_CacheSeconds);
         }
         else
         {
             RedisService.Set <Object>(g_configName, key, args.ReturnValue);
         }
     }
     catch (Exception ex)
     {
     }
     base.OnSuccess(args);
 }