Package org.ehcache

Interface CacheManager

    • Method Detail

      • createCache

        <K,​V> Cache<K,​V> createCache​(String alias,
                                                 CacheConfiguration<K,​V> config)
        Creates a Cache in this CacheManager according to the specified CacheConfiguration.

        The returned Cache will be in status AVAILABLE.

        Type Parameters:
        K - the key type for the cache
        V - the value type for the cache
        Parameters:
        alias - the alias under which the cache will be created
        config - the configuration of the cache to create
        Returns:
        the created and available Cache
        Throws:
        IllegalArgumentException - if there is already a cache registered with the given alias
        IllegalStateException - if the cache creation fails
      • createCache

        <K,​V> Cache<K,​V> createCache​(String alias,
                                                 Builder<? extends CacheConfiguration<K,​V>> configBuilder)
        Creates a Cache in this CacheManager according to the specified CacheConfiguration provided through a Builder.

        The returned Cache will be in status AVAILABLE.

        Type Parameters:
        K - the key type for the cache
        V - the value type for the cache
        Parameters:
        alias - the alias under which the cache will be created
        configBuilder - the builder for the configuration of the cache to create
        Returns:
        the created and available Cache
        Throws:
        IllegalArgumentException - if there is already a cache registered with the given alias
        IllegalStateException - if the cache creation fails
      • getCache

        <K,​V> Cache<K,​V> getCache​(String alias,
                                              Class<K> keyType,
                                              Class<V> valueType)
        Retrieves the Cache associated with the given alias, if one is known.
        Type Parameters:
        K - the key type for the cache
        V - the value type for the cache
        Parameters:
        alias - the alias under which to look the Cache up
        keyType - the Cache key class
        valueType - the Cache value class
        Returns:
        the Cache associated with the given alias, null if no such cache exists
        Throws:
        IllegalArgumentException - if the keyType or valueType do not match the ones with which the Cache was created
      • removeCache

        void removeCache​(String alias)
        Removes the Cache associated with the alias provided, if one is known.

        When the cache is removed, it will release all resources it used.

        Parameters:
        alias - the alias for which to remove the Cache
      • getStatus

        Status getStatus()
        Returns the current Status of this CacheManager.
        Returns:
        the current Status
      • getRuntimeConfiguration

        Configuration getRuntimeConfiguration()
        Returns the current Configuration used by this CacheManager.
        Returns:
        the configuration instance backing this CacheManager