Skip to content
Snippets Groups Projects
Commit f8447523 authored by Ruben Backx's avatar Ruben Backx :coffee:
Browse files

Merge branch '74-make-person-cache-timeout-configurable' into 'development'

Resolve "Make person cache timeout configurable"

Closes #74

See merge request !103
parents 4f1f5e36 08724bcb
No related tags found
No related merge requests found
......@@ -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) {
......
......
......@@ -30,6 +30,8 @@ submit:
username: {{auta-username}}
password: {{auta-password}}
timeout: 1800 # in seconds
cache:
person-timeout: 60 # in seconds
spring:
profiles:
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment