📄 weathercacheinterceptor.java
字号:
package org.signalon.weather.cache;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
public class WeatherCacheInterceptor implements MethodInterceptor {
private WeatherCache cache;
public void setCache(WeatherCache cache) {
this.cache = cache;
}
public Object invoke(MethodInvocation invocation) throws Throwable {
Object[] args = invocation.getArguments();
String key = (String) args[0];
System.out.println(key);
if (cache.isKeyInCache(key)) {
System.out.println("call the data in Cache......");
return cache.get(key);
} else {
Object value = invocation.proceed();
cache.put(key, (String) value);
return value;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -