I read from spring @Cacheable
docs (https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/cache/annotation/Cacheable.html#condition--)
that condition
can specify conditions on method arguments using SpEL.
I have been trying the same out but failing. Here is my method:
public static final String myStr = "4";
@Cacheable(condition="#!req.id.equals("+myStr+")")
public Response myCall(Request req){}
and here is my Request
POJO:
public class Request{
private String id;
public String getId(){
return this.id;
}
public void setId(String id){
this.id = id;
}
}
But it's failing with spring SpEL exceptions, saying that '!' is invalid. Can someone please help me out get the condition right?