Ehcache is an open source, standards-based cache that boosts performance, offloads your database, and simplifies scalability. It's the most widely-used Java-based cache because it's robust, proven, full-featured, and integrates with other popular libraries and frameworks. Ehcache scales from in-process caching, all the way to mixed in-process/out-of-process deployments with terabyte-sized caches.

Ehcache 3.8 is now available!

The major features in this release are:

It requires Java 8+.

Watch for continued rapid improvements to features, stability and performance of the 3.x line throughout the coming months!

As a reminder, Ehcache 3 introduced the following: "Official" builds are available on the project's GitHub release page or from Maven Central - see below.

Getting started with Ehcache 3

You can introduce caching to your Java application quite easily with Ehcache, either using its new, powerful API or using the javax.cache API as defined in the JSR-107 specification.

Using the core Ehcache v3 API

Ehcache 3 has a streamlined, modernized type-safe API (and configuration) that will greatly improve your coding experience when compared to Ehcache 2.x.

Downloading the jars

You can download the jar directly from github or get it from Maven Central:

Coding to the Ehcache 3 API

      CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
               CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,

      Cache preConfigured
          = cacheManager.getCache("preConfigured", Long.class, String.class);

      Cache myCache = cacheManager.createCache("myCache",
          CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,

      myCache.put(1L, "da one!");
      String value = myCache.get(1L);



Using the JSR-107 API

Downloading the jars

You'll need the Ehcache distribution as mentioned above, you'll also require the actual JSR-107 API:

Not quite ready yet?

Read the user documentation for everything you've been wondering about the new API!

Getting started with Ehcache 2

You can introduce caching to your Java application quiet easily with Ehcache 2.

Using the core Ehcache v2 API

Downloading the jars

You can download the jar directly from or get it from Maven Central:

Coding to the Ehcache 2 API

      // Create a cache manager
      final CacheManager cacheManager = new CacheManager();

      // create the cache called "hello-world"
      final Cache cache = cacheManager.getCache("hello-world");

      // create a key to map the data to
      final String key = "greeting";

      // Create a data element
      final Element putGreeting = new Element(key, "Hello, World!");

      // Put the element into the data store

      // Retrieve the data element
      final Element getGreeting = cache.get(key);

      // Print the value

Not quite ready yet?

Read the user documentation for everything you've ever wondered about the Ehcache 2 API!