Reputation: 1004
I am using Spring boot with Caffeine Cache. My key for the cache is a Long and I need the key to be for eg : "1234-RULE" where 1234 is the Long object and -RULE is just a suffix. I tried the below to achieve this :
private final static String RULE_KEY = "#rule.id.concat('-RULE')";
@Cacheable(value = CacheConfig.RULE_OFFSET, key = RULE_KEY)
public BigDecimal getRuleOffset(final Rule rule) {
// some code to fetch the value and return it
}
While debugging, I get the error :
Error occurred while performing the request. Message: EL1004E: Method call: Method concat(java.lang.String) cannot be found on type java.lang.Long
My rule.id is Long and it seems the expression that I'm using to concat the id and the suffix is incorrect. Can you please tell me how to concat a long and string here for my use case.
Upvotes: 0
Views: 676
Reputation: 77167
The documentation for EL can be a bit odd at times, but you can just use +
as a concatenation operator here:
#rule.id + '-RULE'
Upvotes: 1