When caching the DB method, the file data is not written, although as I understand it should. Tell me what's the reason
Configuration file
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ehcache.org/ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true"> <diskStore path="D:\"/> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="100" timeToLiveSeconds="180" overflowToDisk="true" maxElementsOnDisk="10000000" diskPersistent="true" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> <cache name="contacts" maxElementsInMemory="10000000" eternal="false" clearOnFlush="true" overflowToDisk="true" diskPersistent="true" diskExpiryThreadIntervalSeconds="10" timeToIdleSeconds="100" timeToLiveSeconds="180" memoryStoreEvictionPolicy="LFU"> </cache> </ehcache> Service
@Override public List<Contact> regExFilterContacts(String filter) { Pattern pattern = Pattern.compile(filter); Matcher matcher; List<Contact> allContacts = getAllContacts(); if (filter.equals("") || filter.equals(null)) { return allContacts; } logger.info("Start filtering..."); List<Contact> filterListContact = new ArrayList<Contact>(); for (Contact oneContact : allContacts) { matcher = pattern.matcher(oneContact.getName()); if (!matcher.find()) { filterListContact.add(oneContact); } } return filterListContact; } } Controller
@RestController public class MainController { public static final Logger log = Logger.getLogger(MainController.class.getName()); @Autowired private ContactService contactService; @RequestMapping(value = "/hello/contacts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Collection<Contact>> getContacts(@RequestParam(value = "nameFilter", defaultValue = "") String name) { log.info("Filter String is " + name); List<Contact> filterContacts = contactService.regExFilterContacts(name); Integer filterContactSize = filterContacts.size(); if (filterContactSize.equals(0)) { log.info("For you query contacts not found"); return new ResponseEntity<Collection<Contact>>(HttpStatus.NOT_FOUND); } return new ResponseEntity<Collection<Contact>>(filterContacts, HttpStatus.OK); } } thanks in advance