Title Cache

The Titlecache extension module provides a simple way to cache titles of entities for a configurable duration. This can speed up the rendering time of data-heavy objects.

The current implementation uses the Caffeine caching library.

Dependency Management

pom.xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.extensions</groupId>
            <artifactId>causeway-extensions-titlecache</artifactId>
            <scope>import</scope>
            <type>pom</type>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Dependencies

For the module of every entity whose title you want to cache, add the following dependency:

pom.xml
<dependencies>
    <dependency>
        <groupId>org.apache.causeway.extensions</groupId>
        <artifactId>causeway-extensions-titlecache-applib</artifactId>
    </dependency>
</dependencies>

And, in the webapp module of your application, add the following dependency:

pom.xml
<dependencies>
    <dependency>
        <groupId>org.apache.causeway.extensions</groupId>
        <artifactId>causeway-extensions-titlecache-caffeine</artifactId>
    </dependency>
</dependencies>

AppManifest

In your application’s AppManifest (top-level Spring @Configuration used to bootstrap the app), import the CausewayModuleExtTitlecacheCaffeine module.

AppManifest.java
@Configuration
@Import({
        ...
        CausewayModuleExtTitlecacheCaffeine.class,
        ...
})
public class AppManifest {
}

Usage

For each entity class whose title is to be cached, create a subclass of TitleUiEvent that also implements the Cached marker interface, and mark it as the event class fpr @DomainObjectLayout#titleUiEvent:

@DomainObject
@DomainObjectLayout(
    titleUiEvent = Customer.TitleUiEvent.class
)
public class Customer /*...*/ {

    public static class TitleUiEvent extends CausewayModuleApplib.TitleUiEvent<SimpleObject> implements Cached { }

    // ...
}

The titles of these entities will be cached according to the default configuration.

Or, for more control on an given entity, implement the CachedWithCacheSettings interface:

@DomainObject
@DomainObjectLayout(
    titleUiEvent = Customer.TitleUiEvent.class
)
public class Customer /*...*/ {

    public static class TitleUiEvent extends CausewayModuleApplib.TitleUiEvent<SimpleObject> implements CachedWithCacheSettings {
        @Override public int expiryDurationInMinutes() { return 1;}
        @Override public int maxSizeInEntries() {return 50;}
    }

    // ...
}