Spring boot
  • Introduction
  • multiple-modules-spring-boot-apps
  • First Chapter
  • command
  • exe
  • Container Configuration in Spring Boot
  • to lean
  • log
  • EhCache
Powered by GitBook
On this page

Was this helpful?

EhCache

notes for spring boot 1.X + EhCache 3.0 Spring 4

  1. create CacheConfig.jave for the annotation @EnableCaching, @Configuration

  2. spring-bootstrap.xml add xmlns:cache to beans. add <cache:annotation-driven /> for creating beans.

  3. application.properities add one attribute spring.cache.jcache.config=classpath:ehcache.xml

  4. add ehcache.xml: in the xml, eg:

<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
	xmlns='http://www.ehcache.org/v3' xmlns:jsr107='http://www.ehcache.org/v3/jsr107'>

	<service>
		<jsr107:defaults enable-statistics="true" />
	</service>
	<cache alias="vcmmCache">
		<expiry>
			<ttl unit="seconds">10</ttl>
		</expiry>
		<resources>
			<heap unit="entries">2000</heap>
			<offheap unit="MB">100</offheap>
		</resources>
	</cache>
	<cache alias="vcmmCacheMarket">
		<resources>
			<heap unit="entries">2000</heap>
			<offheap unit="MB">100</offheap>
		</resources>
	</cache>
</config>

<resources> is needed for creating CacheManager, also <key-type>, <value-type> are not necessary.

jsr107 works for Spring 4 not Spring 3.

Previouslog

Last updated 5 years ago

Was this helpful?

Ehcache Tiering Options
Logo
Concepts Related to Caching
Logo