Spring Cache

First of all add the MicroStream Cache dependency:

pom.xml
<repositories>
<repository>
<id>microstream-releases</id>
<url>https://repo.microstream.one/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>one.microstream</groupId>
<artifactId>cache</artifactId>
<version>04.00.00-MS-GA</version>
</dependency>
</dependencies>

The core caching abstraction provided by Spring comes in the spring-context module.

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>...</version>
</dependency>

If you use Spring Boot, then add the spring-boot-starter-cache package to add the caching dependencies:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>

To enable caching, Spring makes good use of annotations, much like enabling any other configuration level feature in the framework. The caching feature can be enabled by simply providing a cache setup component.

@SpringBootApplication
@EnableCaching
public class MyApplication
@Component
public class CachingSetup implements JCacheManagerCustomizer
{
@Override
public void customize(CacheManager cacheManager)
{
cacheManager.createCache("my_cache", new MutableConfiguration<>()
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(SECONDS, 10000)))
.setStoreByValue(true)
.setStatisticsEnabled(true));
}
}