Skip to content

Commit e265231

Browse files
author
ansj
committed
add clean cache param
1 parent de39d55 commit e265231

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/java/org/nlpcn/jcoder/run/mvc/processor/ApiMethodInvokeProcessor.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.nlpcn.jcoder.run.mvc.cache.CacheEntry;
1313
import org.nlpcn.jcoder.scheduler.ThreadManager;
1414
import org.nlpcn.jcoder.util.DateUtils;
15+
import org.nlpcn.jcoder.util.Restful;
1516
import org.nlpcn.jcoder.util.StaticValue;
1617
import org.nutz.lang.Lang;
1718
import org.nutz.mvc.ActionContext;
@@ -34,30 +35,32 @@ public void init(NutConfig config, ActionInfo ai) throws Throwable {
3435
}
3536

3637
public void process(ActionContext ac) throws Throwable {
37-
38-
if(ac.getRequest().getParameter("_clean_cache") != null){
39-
cacheEntry = null ;
38+
39+
if (ac.getRequest().getParameter("_clean_cache") != null) {
40+
ac.setMethodReturn(Restful.OK);
41+
cacheEntry = null;
42+
doNext(ac);
43+
return;
4044
}
4145

4246
if (ac.getRequest().getParameter("_rpc_init") != null) {
4347
ac.setMethodReturn(StaticValue.okMessage("rpc init ok"));
4448
doNext(ac);
4549
return;
4650
}
47-
51+
4852
String threadName = null;
4953
Task module = (Task) ac.getModule();
5054
Method method = ac.getMethod();
5155
Object[] args = ac.getMethodArgs();
52-
53-
5456

5557
if (!module.codeInfo().getExecuteMethod(method.getName()).isRestful()) {
5658
throw new IllegalAccessException(module.getName() + "/" + method.getName() + " is not public by restful");
5759
}
58-
60+
5961
try {
60-
threadName = module.getName() + "@" + method.getName() + "@" + ac.getRequest().getRemoteAddr() + "@" + DateUtils.formatDate(new Date(), "yyyyMMddHHmmss") + "@" + al.getAndIncrement();
62+
threadName = module.getName() + "@" + method.getName() + "@" + ac.getRequest().getRemoteAddr() + "@" + DateUtils.formatDate(new Date(), "yyyyMMddHHmmss") + "@"
63+
+ al.getAndIncrement();
6164
ThreadManager.add2ActionTask(threadName, Thread.currentThread());
6265
Object result = executeByCache(module, method, args);
6366
ac.setMethodReturn(result);
@@ -75,6 +78,7 @@ public void process(ActionContext ac) throws Throwable {
7578

7679
/**
7780
* 执行一个task,利用缓存,rpc框架也调用这个
81+
*
7882
* @param task
7983
* @param method
8084
* @param args

0 commit comments

Comments
 (0)