Skip to content
Snippets Groups Projects
Commit 18f86bb3 authored by Otto Visser's avatar Otto Visser
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 8824c471 554ea0bf
Branches
Tags
2 merge requests!105Development,!103Resolve "Make person cache timeout configurable"
......@@ -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