Package net.solarnetwork.central.support
Class CacheSettings
java.lang.Object
net.solarnetwork.central.support.CacheSettings
A standardized cache settings bean.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThediskMaxSizeMbproperty default value.static final booleanThediskPersistentproperty default value.static final longTheheapMaxEntriesproperty default value.static final longThettiproperty default value.static final longThettlproperty default value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<K,V> javax.cache.Cache <K, V> createCache(javax.cache.CacheManager cacheManager, Class<K> keyType, Class<V> valueType, String name) Create a cache.longGet the on-disk maximum size, in MB.longGet a on-heap (memory) max number of cached elements.longgetTti()Get the time to idle, in seconds.longgetTtl()Get the time to live, in seconds.booleanGet the disk persistent setting.voidsetDiskMaxSizeMb(long diskMaxSizeMb) Get the on-disk maximum size, in MB.voidsetDiskPersistent(boolean diskPersistent) Set the disk persistent setting.voidsetHeapMaxEntries(long heapMaxEntries) Set the on-heap (memory) max number of cached elements.voidsetTti(long tti) Set the time to idle, in seconds.voidsetTtl(long ttl) Set the time to live, in seconds.
-
Field Details
-
DEFAULT_TIME_TO_IDLE
public static final long DEFAULT_TIME_TO_IDLEThettiproperty default value.- See Also:
-
DEFAULT_TIME_TO_LIVE
public static final long DEFAULT_TIME_TO_LIVEThettlproperty default value.- See Also:
-
DEFAULT_HEAP_MAX_ENTRIES
public static final long DEFAULT_HEAP_MAX_ENTRIESTheheapMaxEntriesproperty default value.- See Also:
-
DEFAULT_DISK_MAX_SIZE_MB
public static final long DEFAULT_DISK_MAX_SIZE_MBThediskMaxSizeMbproperty default value.- See Also:
-
DEFAULT_DISK_PERSISTENT
public static final boolean DEFAULT_DISK_PERSISTENTThediskPersistentproperty 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 typeV- the value type- Parameters:
cacheManager- the cache managerkeyType- the key classvalueType- the value classname- the namesettings- 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
-