I am trying to use single redis cache for storing the response of 2 Webservices- one is POST and one is GET. For GET service there is no request parameter against which I can store the response of Webservice in Redis, when I try to store it with hardcoded Key it gives me below error.
null key returned for cache operation (maybe you are using named params on classes without debug info?) Builder[public java.util.Map com.getResponse() throws com.adapter.framework.assetserviceadaptor.exception.ServiceExceptions] caches=[redis-cache] | key='#AssetCache' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
This is how I am trying to store GET service response
@Cacheable(value="redis-cache",key ="#AssetCache")
public Map<String, AssetDetailBO> getAssetsResponse() throws COAssetServiceExceptions {
try {
log.info("---- CO_STAGE=[ Caching Service ] ---- ");
return mergingBrokerageAndMutulFund(assetServiceImpl.getAssetResponse());
} catch (ServiceExceptions e) {
log.info("---- CO_STAGE=[ Exception while Calling Assets Adapter For COT ] ---- "
+ e.getErrorMessage());
throw e;
}
}
This is how I am storing POST service response, this is working fine.
@Cacheable(value="redis-cache",key ="#customerId")
public CustomerDTO retriveCustomerdetails( String customerId, String modelId,
String requestId) throws COException {
CustomerInfo csDTO;
try {
csDTO = csDTOAdapterImpl.
getCustomerDetails(customerId);
} catch (Exception e) {
e.printStackTrace();
}
return csDTO;
}
2
Answers
You can use
@Cacheable
without the value and other properties like@Cacheable("all-students")
Example:
Set constant key without # like this: