]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/ClockCache.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
9 * Similar to {@link LRUCache}, but based on the CLOCK algorithm with
10 * better concurrent performance in some cases
12 public class ClockCache
extends Cache
{
15 * Create a new cache with a fixed size capacity.
17 * @param capacity The fixed size capacity of the cache
19 public ClockCache(final long capacity
) {
20 super(newClockCache(capacity
, -1, false));
24 * Create a new cache with a fixed size capacity. The cache is sharded
25 * to 2^numShardBits shards, by hash of the key. The total capacity
26 * is divided and evenly assigned to each shard.
27 * numShardBits = -1 means it is automatically determined: every shard
28 * will be at least 512KB and number of shard bits will not exceed 6.
30 * @param capacity The fixed size capacity of the cache
31 * @param numShardBits The cache is sharded to 2^numShardBits shards,
34 public ClockCache(final long capacity
, final int numShardBits
) {
35 super(newClockCache(capacity
, numShardBits
, false));
39 * Create a new cache with a fixed size capacity. The cache is sharded
40 * to 2^numShardBits shards, by hash of the key. The total capacity
41 * is divided and evenly assigned to each shard. If strictCapacityLimit
42 * is set, insert to the cache will fail when cache is full.
43 * numShardBits = -1 means it is automatically determined: every shard
44 * will be at least 512KB and number of shard bits will not exceed 6.
46 * @param capacity The fixed size capacity of the cache
47 * @param numShardBits The cache is sharded to 2^numShardBits shards,
49 * @param strictCapacityLimit insert to the cache will fail when cache is full
51 public ClockCache(final long capacity
, final int numShardBits
,
52 final boolean strictCapacityLimit
) {
53 super(newClockCache(capacity
, numShardBits
, strictCapacityLimit
));
56 private native static long newClockCache(final long capacity
,
57 final int numShardBits
, final boolean strictCapacityLimit
);
58 @Override protected final native void disposeInternal(final long handle
);