Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from ornicar/threadSafeCache

make the cache threadsafe using synchronizedMap - fixes #1
  • Loading branch information...
commit 1bb3d9d043b9c12525d0cce49f7098cf4a70d8bd 2 parents f539fd4 + 690997d
@guillaumebort guillaumebort authored
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) {
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.