Class JCacheFactoryBean<K,V>

java.lang.Object
net.solarnetwork.central.support.JCacheFactoryBean<K,V>
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<javax.cache.Cache<K,V>>, org.springframework.beans.factory.InitializingBean

public class JCacheFactoryBean<K,V> extends Object implements org.springframework.beans.factory.FactoryBean<javax.cache.Cache<K,V>>, org.springframework.beans.factory.InitializingBean
Factory bean for Cache instances.
  • Constructor Details

    • JCacheFactoryBean

      public JCacheFactoryBean(javax.cache.CacheManager cacheManager, Class<K> keyType, Class<V> valueType)
      Constructor.
      Parameters:
      cacheManager - the cache manager
      keyType - the key type
      valueType - the value type
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • getObject

      public javax.cache.Cache<K,V> getObject() throws Exception
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<K>
      Throws:
      Exception
    • getObjectType

      public Class<?> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<K>
    • isSingleton

      public boolean isSingleton()
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<K>
    • setName

      public void setName(String name)
      Set the cache name.
      Parameters:
      name - the name to set
    • setStoreByValue

      public void setStoreByValue(boolean storeByValue)
      Set the store-by-value flag.
      Parameters:
      storeByValue - the store-by-value to set
    • setExpiryPolicy

      public void setExpiryPolicy(JCacheFactoryBean.ExpiryPolicy expiryPolicy)
      Set the expiry policy.
      Parameters:
      expiryPolicy - the expiry policy to set
    • setExpiryDuration

      public void setExpiryDuration(javax.cache.expiry.Duration expiryDuration)
      Set the expiry duration.
      Parameters:
      expiryDuration - the expiry duration to set
    • setReadThrough

      public void setReadThrough(boolean readThrough)
      Set the read-through flag.
      Parameters:
      readThrough - the read-through to set
    • setWriteThrough

      public void setWriteThrough(boolean writeThrough)
      Set the write-through flag.
      Parameters:
      writeThrough - the write-through to set
    • setStatisticsEnabled

      public void setStatisticsEnabled(boolean statisticsEnabled)
      Set the statistics-enabled flag.
      Parameters:
      statisticsEnabled - the statistics-enabled to set
    • setReadThroughLoaderFactory

      public void setReadThroughLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,V>> readThroughLoaderFactory)
      Set the read-through loader factory.
      Parameters:
      readThroughLoaderFactory - the loader to set
    • setWriteThroughWriterFactory

      public void setWriteThroughWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<K,V>> writeThroughWriterFactory)
      Set the write-through writer factory.
      Parameters:
      writeThroughWriterFactory - the writer to set
    • setHeapMaxEntries

      public void setHeapMaxEntries(Integer heapMaxEntries)
      Set the maximum entries to store in main memory.

      This is an EhCache specific vendor extension, that only works if EhCache is available on the classpath.

      Parameters:
      heapMaxEntries - the max heap entries to configure
      Since:
      1.1
    • setDiskMaxSizeMB

      public void setDiskMaxSizeMB(Integer diskMaxSizeMB)
      Set the maximum size, in MB, to store on disk.

      This is an EhCache specific vendor extension, that only works if EhCache is available on the classpath.

      Parameters:
      diskMaxSizeMB - the max disk size to store
      Since:
      1.1
    • isDiskPersistent

      public boolean isDiskPersistent()
      Get the disk persistence setting.
      Returns:
      true if disk storage should be persistent across restarts; defaults to false
      Since:
      1.2
    • setDiskPersistent

      public void setDiskPersistent(boolean diskPersistent)
      Set the disk persistence setting.
      Parameters:
      diskPersistent - true if disk storage should be persistent across restarts; defaults to false, false to clear the disk storage on restart
      Since:
      1.2