I am trying to create a cache key with multiple parameter values.
@Cacheable(cacheNames = "cache_name_", key = "#name + '_' + #id")
private JSONObject getData(String name, String id) throws Exception {
From the above scenario, I name is a mandatory field while id is optional. I want to create key in such a way that,
- If name = "test" and id = null, cache key must be cache_name_test
- If name = "test" and id = "2", cache key must be cache_name_test_2
Currently, the key is forming something like "cache_name_test_null" if the id is not passed in the parameter value
Is it possible to create such key with @Cacheable annotation?