You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/09/11 03:05:47 UTC

[GitHub] carryxyh commented on a change in pull request #2480: 优化缓存括展,支持缓存null值

carryxyh commented on a change in pull request #2480: 优化缓存括展,支持缓存null值
URL: https://github.com/apache/incubator-dubbo/pull/2480#discussion_r216533274
 
 

 ##########
 File path: dubbo-filter/dubbo-filter-cache/src/main/java/org/apache/dubbo/cache/filter/CacheFilter.java
 ##########
 @@ -49,16 +49,33 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
                 String key = StringUtils.toArgumentString(invocation.getArguments());
                 Object value = cache.get(key);
                 if (value != null) {
-                    return new RpcResult(value);
+                	if(value instanceof ValueWrapper ){
+                		return new RpcResult(((ValueWrapper)value).get());
+                	}else{
+                		return new RpcResult(value);
+                	}
                 }
                 Result result = invoker.invoke(invocation);
-                if (!result.hasException() && result.getValue() != null) {
-                    cache.put(key, result.getValue());
+                if (!result.hasException() ) {
+                    cache.put(key, new ValueWrapper(result.getValue()));
                 }
                 return result;
             }
         }
         return invoker.invoke(invocation);
     }
+    
+    static class ValueWrapper {
+        
+		private final Object value;
 
 Review comment:
   format your code, pls

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org