Skip to content
Snippets Groups Projects

Resolve "Make person cache timeout configurable"

Files

@@ -26,6 +26,7 @@ import nl.tudelft.labracore.api.dto.PersonSummaryDTO;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.ApplicationScope;
@@ -34,18 +35,20 @@ import org.springframework.web.context.annotation.ApplicationScope;
public class PersonCacheManager extends TimedCacheManager<Long, PersonSummaryDTO> {
private Map<String, Long> usernameCache = new ConcurrentHashMap<>();
private static long timeout;
@Autowired
private ModelMapper mapper;
@Autowired
private PersonControllerApi api;
/**
* Creates a new person cache by setting the timeout on its timed cache implementation to 5 minutes.
*/
public PersonCacheManager() {
super(5 * 60 * 1000L);
@Autowired
public PersonCacheManager(ModelMapper mapper, PersonControllerApi api, Environment env) {
super(Long.parseLong(env.getProperty("submit.cache.person-timeout")) * 1000L);
this.mapper = mapper;
this.api = api;
}
public PersonSummaryDTO get(String username) {
Loading