Class Cache.Builder<K,V>

java.lang.Object
com.codename1.backend.Cache.Builder<K,V>
Enclosing class:
Cache<K,V>

public static final class Cache.Builder<K,V> extends Object
A cache's settings. Nothing is bounded or expires unless asked.
  • Method Details

    • maximumSize

      public Cache.Builder<K,V> maximumSize(long entries)
      At most entries entries. Excludes maximumWeight.
    • maximumWeight

      public Cache.Builder<K,V> maximumWeight(long weight, Cache.Weigher<K,V> weigher)
      At most weight in total, as weigher weighs entries. Excludes maximumSize.
    • expireAfterWriteMillis

      public Cache.Builder<K,V> expireAfterWriteMillis(long millis)
      Entries expire this long after they are stored.
    • expireAfterAccessMillis

      public Cache.Builder<K,V> expireAfterAccessMillis(long millis)
      Entries expire this long after they were last read or stored.
    • expiry

      public Cache.Builder<K,V> expiry(Cache.Expiry<K,V> expiry)
      Each entry's lifetime from its write, chosen by expiry.
    • removalListener

      public Cache.Builder<K,V> removalListener(Cache.RemovalListener<K,V> listener)
      Told about every removal; see the class description.
    • clock

      public Cache.Builder<K,V> clock(Cache.Clock clock)
      The time source; the default is the monotonic system clock.
    • build

      public Cache<K,V> build()