The JCache add-on integrates the JCache API (a.k.a. JSR 107) which allows to interact with compliant caching providers in a declarative or a programmatic way.

Implementations are not provided by this add-on and must be configured depending on your caching solution.

<dependency>
    <groupId>org.seedstack.addons.jcache</groupId>
    <artifactId>jcache</artifactId>
</dependency>
Show version
dependencies {
    compile("org.seedstack.addons.jcache:jcache:2.1.0")
}

JCache specification jar dependency is required as well:

<dependency>
    <groupId>javax.cache</groupId>
    <artifactId>cache-api</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
</dependency>

The full specification PDF can be found here.

Configuration

You must define the cache(s) you will use in your application in the configuration:

[org.seedstack.jcache]
caches = myCache1, myCache2, ...

You can then further configure each cache specifically by using the org.seedstack.jcache.cache prefix followed by the cache name:

[org.seedstack.jcache.cache.myCache1]
...

Cache provider

If you have exactly one compliant cache provider in the classpath, it will be automatically picked by the cache support. Otherwise you must specify which provider to use for each cache:

[org.seedstack.jcache.cache.myCache1]
provider = fully.qualified.classname.of.caching.Provider

You can also specify a global default provider, which will be picked for every cache without an explicitly specified provider:

[org.seedstack.jcache]
default-provider = fully.qualified.classname.of.default.caching.Provider

Expiry policy factory

You can specify a custom expiry policy factory for each cache:

[org.seedstack.jcache]
expiry-policy-factory = fully.qualified.classname.of.expiry.policy.Factory

An expiry policy factory must implement javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>.

Usage

You must define the cache(s) you will use in your application in the configuration:

[org.seedstack.jcache]
caches = myCache1, myCache2, ...

You can then further configure each cache specifically by using the org.seedstack.jcache.cache prefix followed by the cache name:

[org.seedstack.jcache.cache.myCache1]
...

Cache provider

If you have exactly one compliant cache provider in the classpath, it will be automatically picked by the cache support. Otherwise you must specify which provider to use for each cache:

[org.seedstack.jcache.cache.myCache1]
provider = fully.qualified.classname.of.caching.Provider

You can also specify a global default provider, which will be picked for every cache without an explicitly specified provider:

[org.seedstack.jcache]
default-provider = fully.qualified.classname.of.default.caching.Provider

Expiry policy factory

You can specify a custom expiry policy factory for each cache:

[org.seedstack.jcache]
expiry-policy-factory = fully.qualified.classname.of.expiry.policy.Factory

An expiry policy factory must implement javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>.