Commit 23a64616 authored by Daniel Gerhardt's avatar Daniel Gerhardt

WIP: Enable caching for course and membership data

parent f9aeed27
......@@ -3,6 +3,7 @@ package de.thm.arsnova.connector.client;
import java.nio.charset.Charset;
import org.apache.commons.codec.binary.Base64;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
......@@ -13,6 +14,9 @@ import de.thm.arsnova.connector.model.Courses;
import de.thm.arsnova.connector.model.Membership;
public class ConnectorClientImpl implements ConnectorClient {
public static final String MEMBERSHIPS_CACHE = "lms.memberships";
public static final String COURSES_CACHE = "lms.courses";
private final RestTemplate restTemplate = new RestTemplate();
private static final String ISMEMBER_URI = "/{username}/membership/{courseid}";
......@@ -42,6 +46,7 @@ public class ConnectorClientImpl implements ConnectorClient {
}
@Override
@Cacheable(MEMBERSHIPS_CACHE)
public Membership getMembership(final String username, final String courseid) {
final ResponseEntity<Membership> response = restTemplate.exchange(
buildRequestUri(ISMEMBER_URI),
......@@ -55,6 +60,7 @@ public class ConnectorClientImpl implements ConnectorClient {
}
@Override
@Cacheable(COURSES_CACHE)
public Courses getCourses(final String username) {
final ResponseEntity<Courses> response = restTemplate.exchange(
buildRequestUri(GETCOURSES_URI),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment