Class CacheSettings

java.lang.Object
net.solarnetwork.central.support.CacheSettings

public class CacheSettings extends Object
A standardized cache settings bean.
  • Field Details

    • DEFAULT_TIME_TO_IDLE

      public static final long DEFAULT_TIME_TO_IDLE
      The tti property default value.
      See Also:
    • DEFAULT_TIME_TO_LIVE

      public static final long DEFAULT_TIME_TO_LIVE
      The ttl property default value.
      See Also:
    • DEFAULT_HEAP_MAX_ENTRIES

      public static final long DEFAULT_HEAP_MAX_ENTRIES
      The heapMaxEntries property default value.
      See Also:
    • DEFAULT_DISK_MAX_SIZE_MB

      public static final long DEFAULT_DISK_MAX_SIZE_MB
      The diskMaxSizeMb property default value.
      See Also:
    • DEFAULT_DISK_PERSISTENT

      public static final boolean DEFAULT_DISK_PERSISTENT
      The diskPersistent property default value.
      See Also:
  • Constructor Details

    • CacheSettings

      public CacheSettings()
  • Method Details

    • createCache

      public <K, V> javax.cache.Cache<K,V> createCache(javax.cache.CacheManager cacheManager, Class<K> keyType, Class<V> valueType, String name)
      Create a cache.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      cacheManager - the cache manager
      keyType - the key class
      valueType - the value class
      name - the name
      settings - the settings
      Returns:
      the new cache instance
    • getTti

      public long getTti()
      Get the time to idle, in seconds.
      Returns:
      the time to idle, or 0 for no idle timeout; defaults to DEFAULT_TIME_TO_IDLE
    • setTti

      public void setTti(long tti)
      Set the time to idle, in seconds.
      Parameters:
      tti - the time to idle, or 0 for no idle timeout
    • getTtl

      public long getTtl()
      Get the time to live, in seconds.
      Returns:
      the time to live seconds, or 0 for no life timeout; defaults to DEFAULT_TIME_TO_LIVE
    • setTtl

      public void setTtl(long ttl)
      Set the time to live, in seconds.
      Parameters:
      ttl - the time to live, or 0 for no life timeout
    • getHeapMaxEntries

      public long getHeapMaxEntries()
      Get a on-heap (memory) max number of cached elements.
      Returns:
      the max heap element count, 0 for no limit; defaults to DEFAULT_HEAP_MAX_ENTRIES
    • setHeapMaxEntries

      public void setHeapMaxEntries(long heapMaxEntries)
      Set the on-heap (memory) max number of cached elements.
      Parameters:
      heapMaxEntries - the max heap element count
    • getDiskMaxSizeMb

      public long getDiskMaxSizeMb()
      Get the on-disk maximum size, in MB.
      Returns:
      the on-disk maximum size; defaults to DEFAULT_DISK_MAX_SIZE_MB
    • setDiskMaxSizeMb

      public void setDiskMaxSizeMb(long diskMaxSizeMb)
      Get the on-disk maximum size, in MB.
      Parameters:
      diskMaxSizeMb - the on-disk maximum size, in MB
    • isDiskPersistent

      public boolean isDiskPersistent()
      Get the disk persistent setting.
      Returns:
      true to persist the cache between reboots; defaults to DEFAULT_DISK_PERSISTENT
    • setDiskPersistent

      public void setDiskPersistent(boolean diskPersistent)
      Set the disk persistent setting.
      Parameters:
      diskPersistent - true to persist the cache between reboots