You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2017/05/02 15:18:48 UTC
svn commit: r1793527 -
/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java
Author: mduerig
Date: Tue May 2 15:18:48 2017
New Revision: 1793527
URL: http://svn.apache.org/viewvc?rev=1793527&view=rev
Log:
OAK-5042: Improve caching of segments
Prevent invalidation to happen before loading
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java?rev=1793527&r1=1793526&r2=1793527&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentCache.java Tue May 2 15:18:48 2017
@@ -81,6 +81,13 @@ public class SegmentCache {
}).build();
}
+ private void put(@Nonnull SegmentId id, Segment segment) {
+ // Call loaded *before* putting the segment into the cache as the latter
+ // might cause it to get evicted right away again.
+ id.loaded(segment);
+ cache.put(id, segment);
+ }
+
/**
* Retrieve an segment from the cache or load it and cache it if not yet in the cache.
* @param id the id of the segment
@@ -97,8 +104,7 @@ public class SegmentCache {
return segment;
}
- cache.put(id, segment);
- id.loaded(segment);
+ put(id, segment);
return segment;
} catch (Exception e) {
throw new ExecutionException(e);
@@ -115,8 +121,7 @@ public class SegmentCache {
return;
}
- cache.put(segmentId, segment);
- segmentId.loaded(segment);
+ put(segmentId, segment);
}
/**