i have introduced ehcache in web application. working file when try populate cache after server startup. want populate cache @ time of server startup. , suggestion appreciated.
here code call ehcache on method populate cache after server started.
@transactional @cacheable(value="loadusercache") public list<usersdto> getallusers() { list<users> users = userrepository.findall(); list<usersdto> usersdto = new arraylist<usersdto>(users.size()); (users user : users) { usersdto userdto = mapper.map(user, usersdto.class); usersdto.add(userdto); } return usersdto; } this code working correctly requirement want done @ time of server startup.
what try far achieve is
@cacheable(value = "loadusercache") public void update() { list<users> users = userrepository.findall(); (users user : users) { cachemanager.getcache("loadusercache").put(user.getid(), user); } } calling method in @postconstruct annotation.
Comments
Post a Comment