@@ -31,7 +31,7 @@ public LRUCache(final long capacity) {
3131 * by hash of the key
3232 */
3333 public LRUCache (final long capacity , final int numShardBits ) {
34- super (newLRUCache (capacity , numShardBits , false , 0.0 , 0.0 ));
34+ super (newLRUCache (capacity , numShardBits , false , 0.0 , 0.0 , 0 ));
3535 }
3636
3737 /**
@@ -49,7 +49,7 @@ public LRUCache(final long capacity, final int numShardBits) {
4949 */
5050 public LRUCache (final long capacity , final int numShardBits ,
5151 final boolean strictCapacityLimit ) {
52- super (newLRUCache (capacity , numShardBits , strictCapacityLimit , 0.0 , 0.0 ));
52+ super (newLRUCache (capacity , numShardBits , strictCapacityLimit , 0.0 , 0.0 , 0 ));
5353 }
5454
5555 /**
@@ -71,7 +71,7 @@ public LRUCache(final long capacity, final int numShardBits,
7171 */
7272 public LRUCache (final long capacity , final int numShardBits , final boolean strictCapacityLimit ,
7373 final double highPriPoolRatio ) {
74- super (newLRUCache (capacity , numShardBits , strictCapacityLimit , highPriPoolRatio , 0.0 ));
74+ super (newLRUCache (capacity , numShardBits , strictCapacityLimit , highPriPoolRatio , 0.0 , 0 ));
7575 }
7676
7777 /**
@@ -96,12 +96,36 @@ public LRUCache(final long capacity, final int numShardBits, final boolean stric
9696 public LRUCache (final long capacity , final int numShardBits , final boolean strictCapacityLimit ,
9797 final double highPriPoolRatio , final double lowPriPoolRatio ) {
9898 super (newLRUCache (
99- capacity , numShardBits , strictCapacityLimit , highPriPoolRatio , lowPriPoolRatio ));
99+ capacity , numShardBits , strictCapacityLimit , highPriPoolRatio , lowPriPoolRatio , 0 ));
100+ }
101+
102+ /**
103+ * Create a new cache with a secondary cache tier.
104+ * Evicted entries go to secondary cache, secondary hits promote back to primary.
105+ * numShardBits = -1 means it is automatically determined: every shard
106+ * will be at least 512KB and number of shard bits will not exceed 6.
107+ *
108+ * @param capacity The fixed size capacity of the primary cache
109+ * @param numShardBits The cache is sharded to 2^numShardBits shards,
110+ * by hash of the key
111+ * @param strictCapacityLimit insert to the cache will fail when cache is full
112+ * @param highPriPoolRatio percentage of the cache reserves for high priority
113+ * entries
114+ * @param lowPriPoolRatio percentage of the cache reserves for low priority
115+ * entries
116+ * @param secondaryCache the secondary cache instance, or null for no secondary cache
117+ */
118+ public LRUCache (final long capacity , final int numShardBits , final boolean strictCapacityLimit ,
119+ final double highPriPoolRatio , final double lowPriPoolRatio ,
120+ final SecondaryCache secondaryCache ) {
121+ super (newLRUCache (
122+ capacity , numShardBits , strictCapacityLimit , highPriPoolRatio , lowPriPoolRatio ,
123+ secondaryCache == null ? 0 : secondaryCache .nativeHandle_ ));
100124 }
101125
102126 private static native long newLRUCache (final long capacity , final int numShardBits ,
103127 final boolean strictCapacityLimit , final double highPriPoolRatio ,
104- final double lowPriPoolRatio );
128+ final double lowPriPoolRatio , final long secondaryCacheHandle );
105129 @ Override
106130 protected final void disposeInternal (final long handle ) {
107131 disposeInternalJni (handle );
0 commit comments