Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I make a cache for InterceptorChain.pluginAll #2832

Open
sunyongfengchina opened this issue Feb 28, 2023 · 1 comment
Open

Can I make a cache for InterceptorChain.pluginAll #2832

sunyongfengchina opened this issue Feb 28, 2023 · 1 comment

Comments

@sunyongfengchina
Copy link

`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
Copy link
Member

harawata commented Mar 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants