Skip to content
Browse files

make the cache threadsafe using synchronizedMap - fixes #1

  • Loading branch information...
1 parent f539fd4 commit 690997d98cec61aa9d4f3ba84f335588d2bfadf7 @ornicar ornicar committed Nov 7, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/main/java/io/prismic/Cache.java
View
6 src/main/java/io/prismic/Cache.java
@@ -24,7 +24,7 @@ public JsonNode get(String url) {
public static class BuiltInCache implements Cache {
- private final org.apache.commons.collections.map.LRUMap cache;
+ private final java.util.Map<String, Entry> cache;
static class Entry {
public final Long expiration;
@@ -36,7 +36,7 @@ public Entry(Long expiration, JsonNode value) {
}
public BuiltInCache(int maxDocuments) {
- this.cache = new org.apache.commons.collections.map.LRUMap(maxDocuments);
+ this.cache = java.util.Collections.synchronizedMap(new org.apache.commons.collections.map.LRUMap(maxDocuments));
}
public void set(String url, Long expiration, JsonNode response) {
@@ -53,4 +53,4 @@ public JsonNode get(String url) {
}
-}
+}

0 comments on commit 690997d

Please sign in to comment.
Something went wrong with that request. Please try again.