类 CacheBuilder<K,​V>


  • public class CacheBuilder<K,​V>
    extends java.lang.Object
    Cache builder.
    作者:
    zzq
    • 字段详细资料

      • DEFAULT_MAXIMUMSIZE

        private static final int DEFAULT_MAXIMUMSIZE
        另请参阅:
        常量字段值
      • DEFAULT_INITIALIZE_CAPACITY

        private static final int DEFAULT_INITIALIZE_CAPACITY
        另请参阅:
        常量字段值
      • DEFAULT_EXPIRE_NANOS

        private static final int DEFAULT_EXPIRE_NANOS
        另请参阅:
        常量字段值
      • expireNanos

        private long expireNanos
      • maximumSize

        private int maximumSize
      • initializeCapacity

        private int initializeCapacity
      • sync

        private boolean sync
      • lru

        private boolean lru
    • 构造器详细资料

      • CacheBuilder

        public CacheBuilder()
    • 方法详细资料

      • builder

        public static <K,​V> CacheBuilder<K,​V> builder()
      • expireNanos

        public CacheBuilder<K,​V> expireNanos​(long duration,
                                                   java.util.concurrent.TimeUnit unit)
        Set expiration time.
      • checkExpireNanos

        private void checkExpireNanos​(long duration,
                                      java.util.concurrent.TimeUnit unit)
      • maximumSize

        public CacheBuilder<K,​V> maximumSize​(int maximumSize)
        Set the maximum capacity of the cache pair.
        参数:
        maximumSize - maximum capacity
      • sync

        public CacheBuilder<K,​V> sync​(boolean sync)
        Set whether the cache method is synchronized.
        参数:
        sync - if sync value is true, each method of the constructed cache is synchronized.
      • lru

        public CacheBuilder<K,​V> lru​(boolean lru)
        Does the constructed cache support lru.
        参数:
        lru - If the cache built for true is an lru cache.
      • initializeCapacity

        public CacheBuilder<K,​V> initializeCapacity​(int initializeCapacity)
        Set the initial capacity of the cache pair.
        参数:
        initializeCapacity - initialize capacity
      • build

        public Cache<K,​V> build()
        Build the cache according to the builder attribute.