mybatis / mybatis-3

MyBatis SQL mapper framework for Java
http://mybatis.github.io/mybatis-3/
Apache License 2.0
19.79k stars 12.86k forks source link

Can I make a cache for InterceptorChain.pluginAll #2832

Open sunyongfengchina opened 1 year ago

sunyongfengchina commented 1 year ago

`public class InterceptorChain {

private final List interceptors = new ArrayList<>();

//When the same proxy object is called multiple times, the object returned each time is the same result. Can I cache proxy objects and final objects with key value pairs? public Object pluginAll(Object target) { for (Interceptor interceptor : interceptors) { target = interceptor.plugin(target); } return target; }

public void addInterceptor(Interceptor interceptor) { interceptors.add(interceptor); }

public List getInterceptors() { return Collections.unmodifiableList(interceptors); }

} `

harawata commented 1 year ago

Hello @sunyongfengchina ,

Could you explain why do you want to do it? Caching consumes memory, so it's not "free" like some people think.

There also is another possibly related request #1993 if you are interested.