I have the following code for getting data from db.
@Cacheable()
public List getAllSystem(String client,Integer pageNumber,Integer pageSize,String sortBy, String sortDirection)
{
Pageable p=PageRequest.of(pageNumber,pageSize,sort);
Page sys=sysDao.findAll(p);
List allsys=sys.getContent();
return allsys;
}
And following code for adding new entity
@CachePut()
public SystemEntity addSystem(String client,SystemEntity sys)
{
Integer maxId = sysDao.findSystemMaxId();
System.out.println(“maxId”+maxId);
sys.setSystemId(maxId);
sys.setCreatedDate(new Date());
System.out.println(sys);
return sysDao.save(sys);
}
If I am not wrong, we should use the same key for @Cacheable and @Cacheput. But we dont have any common variable to use as key. Please help out of this. Thanks in advance.
Please give us the code using key of @Cacheable and @Cacheput.