]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/LRUCache.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
9 * Least Recently Used Cache
11 public class LRUCache
extends Cache
{
14 * Create a new cache with a fixed size capacity
16 * @param capacity The fixed size capacity of the cache
18 public LRUCache(final long capacity
) {
19 this(capacity
, -1, false, 0.0);
23 * Create a new cache with a fixed size capacity. The cache is sharded
24 * to 2^numShardBits shards, by hash of the key. The total capacity
25 * is divided and evenly assigned to each shard.
26 * numShardBits = -1 means it is automatically determined: every shard
27 * will be at least 512KB and number of shard bits will not exceed 6.
29 * @param capacity The fixed size capacity of the cache
30 * @param numShardBits The cache is sharded to 2^numShardBits shards,
33 public LRUCache(final long capacity
, final int numShardBits
) {
34 super(newLRUCache(capacity
, numShardBits
, false,0.0));
38 * Create a new cache with a fixed size capacity. The cache is sharded
39 * to 2^numShardBits shards, by hash of the key. The total capacity
40 * is divided and evenly assigned to each shard. If strictCapacityLimit
41 * is set, insert to the cache will fail when cache is full.
42 * numShardBits = -1 means it is automatically determined: every shard
43 * will be at least 512KB and number of shard bits will not exceed 6.
45 * @param capacity The fixed size capacity of the cache
46 * @param numShardBits The cache is sharded to 2^numShardBits shards,
48 * @param strictCapacityLimit insert to the cache will fail when cache is full
50 public LRUCache(final long capacity
, final int numShardBits
,
51 final boolean strictCapacityLimit
) {
52 super(newLRUCache(capacity
, numShardBits
, strictCapacityLimit
,0.0));
56 * Create a new cache with a fixed size capacity. The cache is sharded
57 * to 2^numShardBits shards, by hash of the key. The total capacity
58 * is divided and evenly assigned to each shard. If strictCapacityLimit
59 * is set, insert to the cache will fail when cache is full. User can also
60 * set percentage of the cache reserves for high priority entries via
62 * numShardBits = -1 means it is automatically determined: every shard
63 * will be at least 512KB and number of shard bits will not exceed 6.
65 * @param capacity The fixed size capacity of the cache
66 * @param numShardBits The cache is sharded to 2^numShardBits shards,
68 * @param strictCapacityLimit insert to the cache will fail when cache is full
69 * @param highPriPoolRatio percentage of the cache reserves for high priority
72 public LRUCache(final long capacity
, final int numShardBits
,
73 final boolean strictCapacityLimit
, final double highPriPoolRatio
) {
74 super(newLRUCache(capacity
, numShardBits
, strictCapacityLimit
,
78 private native static long newLRUCache(final long capacity
,
79 final int numShardBits
, final boolean strictCapacityLimit
,
80 final double highPriPoolRatio
);
81 @Override protected final native void disposeInternal(final long handle
);