Package org.rocksdb

Class ClockCache

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ClockCache
    extends Cache
    Similar to LRUCache, but based on the CLOCK algorithm with better concurrent performance in some cases
    • Constructor Detail

      • ClockCache

        public ClockCache​(long capacity)
        Create a new cache with a fixed size capacity.
        Parameters:
        capacity - The fixed size capacity of the cache
      • ClockCache

        public ClockCache​(long capacity,
                          int numShardBits)
        Create a new cache with a fixed size capacity. The cache is sharded to 2^numShardBits shards, by hash of the key. The total capacity is divided and evenly assigned to each shard. numShardBits = -1 means it is automatically determined: every shard will be at least 512KB and number of shard bits will not exceed 6.
        Parameters:
        capacity - The fixed size capacity of the cache
        numShardBits - The cache is sharded to 2^numShardBits shards, by hash of the key
      • ClockCache

        public ClockCache​(long capacity,
                          int numShardBits,
                          boolean strictCapacityLimit)
        Create a new cache with a fixed size capacity. The cache is sharded to 2^numShardBits shards, by hash of the key. The total capacity is divided and evenly assigned to each shard. If strictCapacityLimit is set, insert to the cache will fail when cache is full. numShardBits = -1 means it is automatically determined: every shard will be at least 512KB and number of shard bits will not exceed 6.
        Parameters:
        capacity - The fixed size capacity of the cache
        numShardBits - The cache is sharded to 2^numShardBits shards, by hash of the key
        strictCapacityLimit - insert to the cache will fail when cache is full
    • Method Detail