### Ehcache Cache

code

docs

tests

EntityStore cache backed by EhCache.

Table 58. Artifact

Group ID | Artifact ID | Version
--- | --- | ---
org.qi4j.extension | org.qi4j.extension.cache-ehcache | 2.1

Not all EntityStore implementations use the Cache extension, so check the implementation details of the EntityStore whether the cache extension can bring any benefits or not.

#### Assembly

Assembly is done using the provided Assembler:

    public void assemble( ModuleAssembly module )
        throws AssemblyException
    {
    [...snip...]

        new EhCacheAssembler().
            withConfig( confModule, Visibility.layer ).
            assemble( module );
    }

#### Configuration

Here are the configuration properties for the EhCache EntityStore Cache:

    public interface EhCacheConfiguration
        extends ConfigurationComposite
    {

        @Optional @UseDefaults
        Property<Boolean> clearOnFlush();

        @Optional @UseDefaults
        Property<Integer> diskAccessStripes();

        @Optional @UseDefaults
        Property<Long> diskExpiryThreadIntervalSeconds();

        /**
         * Cache Persistence Strategy.
         *
         * Can be:
         * <ul>
         *   <li>LOCALTEMPSWAP: Standard open source (non fault-tolerant) on-disk persistence.</li>
         *   <li>LOCALRESTARTABLE: Enterprise fault tolerant persistence.</li>
         *   <li>NONE: No persistence.</li>
         *   <li>DISTRIBUTED: Terracotta clustered persistence (requires a Terracotta clustered cache).</li>
         * </ul>
         * Defaults to NONE.
         */
        @Optional
        Property<Strategy> persistenceStrategy();

        @Optional @UseDefaults
        Property<String> diskStorePath();

        @Optional @UseDefaults
        Property<Integer> diskSpoolBufferSizeMB();

        @Optional @UseDefaults
        Property<Boolean> eternal();

        @Optional @UseDefaults
        Property<Boolean> loggingEnabled();

        /**
         * Number of objects the ehCache should keep in memory.
         * Defaults to 1000
         *
         * @return The maximum number of elements to be kept in memory.
         */
        @Optional @UseDefaults
        Property<Integer> maxElementsInMemory();

        @Optional @UseDefaults
        Property<Integer> maxElementsOnDisk();

        @Optional @UseDefaults
        Property<String> memoryStoreEvictionPolicy();

        @Optional @UseDefaults
        Property<String> name();

        @Optional @UseDefaults
        Property<String> transactionalMode();

        @Optional @UseDefaults
        Property<Long> timeToLiveSeconds();

        @Optional @UseDefaults
        Property<Long> timeToIdleSeconds();

        @Optional @UseDefaults
        Property<String> cacheManagerName();

        @Optional @UseDefaults
        Property<String> monitoring();

        @Optional @UseDefaults
        Property<Boolean> updateCheck();
    }