This project has retired. For details please refer to its Attic page.
Ehcache Cache
Polygene™
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

Ehcache Cache

code

docs

tests

EntityStore cache backed by EhCache.

Table 63. Artifact

Group IDArtifact IDVersion

org.apache.polygene.extensions

org.apache.polygene.extension.cache-ehcache

3.0.0


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 )
{
  [...snip...]

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

Configuration

Here are the configuration properties for the EhCache EntityStore Cache:

public interface EhCacheConfiguration {

    /**
     * Heap tier size.
     *
     * Default to 1MB, you may want to change this.
     *
     * @return Heap tier size
     */
    @UseDefaults( "1" )
    Property<Long> heapSize();

    /**
     * Heap tier size unit.
     *
     * @return Heap tier size unit
     */
    @OneOf( { "B", "KB", "MB", "GB", "TB", "PB" } )
    @UseDefaults( "MB" )
    Property<String> heapUnit();

    /**
     * Optional off-heap tier size.
     *
     * @return Optional off-heap tier size
     */
    @Optional
    Property<Long> offHeapSize();

    /**
     * Off-heap tier size unit.
     *
     * @return Off-heap tier size unit
     */
    @OneOf( { "B", "KB", "MB", "GB", "TB", "PB" } )
    @UseDefaults( "MB" )
    Property<String> offHeapUnit();

    /**
     * Optional disk tier size.
     *
     * @return Optional disk tier size
     */
    @Optional
    Property<Long> diskSize();

    /**
     * Disk tier size unit.
     *
     * @return Disk tier size unit
     */
    @OneOf( { "B", "KB", "MB", "GB", "TB", "PB" } )
    @UseDefaults( "MB" )
    Property<String> diskUnit();

    /**
     * If the disk tier is persistent or not.
     *
     * @return If the disk tier is persistent or not
     */
    @UseDefaults
    Property<Boolean> diskPersistent();

    /**
     * Maximum size of cached objects.
     *
     * @return Maximum size of cached objects
     */
    @Optional
    Property<Long> maxObjectSize();

    /**
     * Unit for maximum size of cached objects.
     *
     * @return Unit for maximum size of cached objects
     */
    @OneOf( { "B", "KB", "MB", "GB", "TB", "PB" } )
    @UseDefaults( "MB" )
    Property<String> maxObjectSizeUnit();

    /**
     * Maximum cached object graph depth.
     *
     * @return Maximum cached object graph depth
     */
    @Optional
    Property<Long> maxObjectGraphDepth();

    /**
     * Expiry policy.
     *
     * @return Expiry policy
     */
    @OneOf( { "NONE", "TIME_TO_IDLE", "TIME_TO_LIVE" } )
    @UseDefaults( "NONE" )
    Property<String> expiry();

    /**
     * Expiry length.
     *
     * @return Expiry length
     */
    @Optional
    Property<Long> expiryLength();

    /**
     * Expiry time unit.
     *
     * @return Expiry time unit
     */
    @OneOf( { "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" } )
    @UseDefaults( "SECONDS" )
    Property<String> expiryTimeUnit();
}

Cache overflow to disk may be configured using the FileConfig Library. If the FileConfig library is not in use, then it defaults to a temporary directory in java.io.tmpdir.