A List of Cache Providers
Performance

A List of Cache Providers

Recently, we described several criteria to look at to choose a cache . Now it’s time to list Java cache providers based on these criteria.

Java Caching System

JCS is a distributed caching system written in Java. It is intended to speed up applications by providing a means to manage cached data of various dynamic natures. Like any caching system, JCS is most useful for high read, low put applications. Latency times drop sharply and bottlenecks move away from the database in an effectively cached system.

—- https://commons.apache.org/proper/commons-jcs/index.html

| Name | Java Caching System | | Provider | The Apache Foundation | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2002 | | Last commit | c6b852c | | GitHub stars | 76 | | Configuration | File-based (cache.ccf) |

Configuration
jcs.default= jcs.default.cacheattributes=\ org.apache.commons.jcs3.engine.CompositeCacheAttributes jcs.default.cacheattributes.MaxObjects=1000 jcs.default.cacheattributes.MemoryCacheName=\ org.apache.commons.jcs3.engine.memory.lru.LRUMemoryCache

Guava

Guava is a set of core Java libraries from Google that includes new collection types (such as multimap and multiset), immutable collections, a graph library, and utilities for concurrency, I/O, hashing, caching, primitives, strings, and more! It is widely used on most Java projects within Google, and widely used by many other companies as well.

https://github.com/google/guava

| Name | Guava | | Provider | Google | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2010 | | Last commit | ba690ba | | GitHub stars | 42.6k | | Configuration | Programmatic |

Configuration
var cache = CacheBuilder.newBuilder() .maximumSize(1000) .build()
A third-party project provides a JCache adapter
The get method accepts a Callable parameter that allows to get a value from the cache or compute it and store it if it’s not found
The API uses soft and weak references in keys and values
Allows you to attach event handlers when entries are evicted

Caffeine

Caffeine is a high performance , near optimal caching library. For more details, see our user’s guide and browse the API docs for the latest release.

https://github.com/ben-manes/caffeine

| Name | Caffeine | | Provider | Ben Manes | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2014 | | Last commit | 41abb08 | | GitHub stars | 10.6k | | Configuration | Programmatic |

Configuration
var cache = Caffeine.newBuilder() .maximumSize(1000) .build()
var cache = Caffeine.newBuilder() .maximumSize(1000) .<Long, String>buildAsync(); // 1 CompletableFuture future = cache.get(1L, k -> expensiveLookup(1L)); 1. Build an asynchronous cache
> * Automatic loading of entries into the cache, optionally asynchronously > * Size-based eviction when a maximum is exceeded based on frequency and recency > * Time-based expiration of entries, measured since last access or last write > * Asynchronously refresh when the first stale request for an entry occurs > * Keys automatically wrapped in weak references > * Values automatically wrapped in weak or soft references > * Notification of evicted (or otherwise removed) entries > * Writes propagated to an external resource > * Accumulation of cache access statistics

Ehcache

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.

—- https://www.ehcache.org/

| Name | Ehcache | | Provider | Software AG | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2009 | | Last commit | 212c63c | | GitHub stars | 1.7k | | Configuration | Programmatic |

Configuration
var cacheManager = CacheManagerBuilder .newCacheManagerBuilder() .withCache( "cache", CacheConfigurationBuilder.newCacheConfigurationBuilder( Long.class, String.class, ResourcePoolsBuilder.heap(10) ) ).build(); cacheManager.init(); var cache = cacheManager.getCache( "cache", Long.class, String.class );
Terracota is the Enterprise version of Ehcache. It provides distributed capabilities.

Infinispan

Infinispan is an open-source in-memory data grid that offers flexible deployment options and robust capabilities for storing, managing, and processing data. Infinispan provides a key/value data store that can hold all types of data, from Java objects to plain text. Infinispan distributes your data across elastically scalable clusters to guarantee high availability and fault tolerance, whether you use Infinispan as a volatile cache or a persistent data store.
https://infinispan.org/

| Name | Infinispan | | Provider | RedHat | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2009 | | Last commit | 3dd18ce | | GitHub stars | 910 | | Configuration | Programmatic |

Configuration
var cacheManager = new DefaultCacheManager(); cacheManager.defineConfiguration("cache", new ConfigurationBuilder().memory().maxSize("1000").build() ); var cache = cacheManager.<Long, String>getCache("cache");
CompletableFuture<String> future = cache.getAsync(1L, k -> expensiveLookup(1L));
> * Interoperability: access data across multiple protocols and programming languages > * Resilient and Fault Tolerant Data: ensure data is always available to meet demanding workloads > * ACID Transactions: guarantee that data is always valid and consistent > * Clustered Processing: process data in real-time without burdening resources > * Queries: perform simple, accurate, and fast searches across distributed data sets

Coherence Community Edition

Coherence is scalable, fault-tolerant, cloud-ready, distributed platform for building grid-based applications and reliably storing data. The product is used at scale, for both compute and raw storage, in a vast array of industries such as critical financial trading systems, high performance telecommunication products, and eCommerce applications.

—- https://coherence.community/latest/21.06/docs/

| Name | Coherence | | Provider | Oracle | | Source | GitHub | | License | Universal Permissive License | | Inception date | 2001 | | Last commit | 5f0b968 | | GitHub stars | 340 | | Configuration | File-based |

Configuration
<?xml version="1.0"?> <cache-config> <caching-scheme-mapping> <cache-mapping> <cache-name>cache</cache-name> <scheme-name>local</scheme-name> </cache-mapping> </caching-scheme-mapping> <caching-schemes> <local-scheme> <scheme-name>local</scheme-name> <high-units>1000</high-units> </local-scheme> </caching-schemes> </cache-config>
var cache = CacheFactory .<Long, String>getCache("cache") .async(); CompletableFuture future = cache.get(1L);
Commercial versions are available: * * Enterprise * Grid
* Clustering and Data Sharding * Scalability and High Avalability * Disk-Based Persistence * Key-Value Data Store * Parallel Queries * Efficient Aggregation * In-Place Processing * Sophisticated Event Model

Ignite

Distributed Database For High-Performance Computing With In-Memory Speed

https://ignite.apache.org/

| Name | Ignite | | Provider | GridGain | | Source | GitHub | | License | Apache 2.0 | | Inception date | ? | | Open-Sourced | 2014 | | Last commit | 73a687d | | GitHub stars | 4k | | Configuration | Programmatic |

Configuration
var cacheCfg = new CacheConfiguration<Long, String>(); cacheCfg.setOnheapCacheEnabled(true); cacheCfg.setEvictionPolicyFactory( () -> new LruEvictionPolicy<>(1000) ); cacheCfg.setName("cache"); var cfg = new IgniteConfiguration(); cfg.setCacheConfiguration(cacheCfg); ignite = Ignition.start(cfg); var cache = ignite.getOrCreateCache("cache");
IgniteFuture<String> future = cache.getAsync(1L); // 1 1. Ignite provides its own asynchronous primitives, which are different from the JDK’s
GridGrain offers an enterprise version of Ignite named GridGain In-Memory Computing Platform

Geode

Apache Geode is a data management platform that provides real-time, consistent access to data-intensive applications throughout widely distributed cloud architectures.

Apache Geode pools memory, CPU, network resources, and optionally local disk across multiple processes to manage application objects and behavior. It uses dynamic replication and data partitioning techniques to implement high availability, improved performance, scalability, and fault tolerance. In addition to being a distributed data container, Apache Geode is an in-memory data management system that provides reliable asynchronous event notifications and guaranteed message delivery.

https://github.com/apache/geode

| Name | Geode | | Provider | Pivotal | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2015 | | Open-Sourced | 2019 | | Last commit | a21df0b | | GitHub stars | 2k | | Configuration | File-based and programmatic |

Configuration
var cache = new CacheFactory().create(); var factory = cache.<Long, String>createRegionFactory(); factory.setEvictionAttributes( EvictionAttributes.createLRUEntryAttributes(1000) ); var region = factory.create("cache");
> […] main features and key functionality : > * High Read-and-Write Throughput > * Low and Predictable Latency > * High Scalability > * Continuous Availability > * Reliable Event Notifications > * Parallelized Application Behavior on Data Stores > * Shared-Nothing Disk Persistence > * Reduced Cost of Ownership > * Single-Hop Capability for Client/Server > * Client/Server Security > * Multisite Data Distribution > * Continuous Querying > * Heterogeneous Data Sharing

Hazelcast

I work for Hazelcast at the time of this writing.

Hazelcast is a streaming and memory-first application platform for fast, stateful, data-intensive workloads on-premises, at the edge or as a fully managed cloud service.

—- https://hazelcast.com/

| Name | Hazelcast | | Provider | Hazelcast | | Source | GitHub | | License | Apache 2.0 | | Inception date | 2008 | | Last commit | de91d6b | | GitHub stars | 4.6k | | Configuration | File-based and programmatic |

Configuration
var hazelcast = Hazelcast.newHazelcastInstance(); hazelcast.getConfig() .getMapConfig("cache") .getEvictionConfig() .setSize(1000); var map = hazelcast.getMap("cache");
CompletionStage<String> stage = cache.getAsync(1L);
> * Distributed computation, data structures, and events > * Streaming data processing > * Connectors to read from/write to systems like Apache Kafka, JMS, JDBC and HDMS > * Querying with SQL and predicates > * CP subsystem for distributed coordination use cases > * JCache implementation > * Replication of web sessions (filter, Tomcat, Jetty based) > * Administration and monitoring utilities including Management Center, JMX, metrics and diagnostics

The following Maven project shows a simple key get-put for each cache.

I tried my best to provide accurate objective information. Please let me know in the comments if something is wrong.

To go further:

Orginally published at A Java Geek on October 31st, 2021

*[MRU]: Most Recently Used *[LFU]: Least Frequently Used *[FIFO]: First In First Out *[TTL]: Time-to-Live *[MFU]: Most Frequently Used *[LRU]: Least Recently Used

Written by

Nicolas Frankel

Technologist focusing on cloud-native technologies, DevOps, CI/CD pipelines, and system observability. His focus revolves around creating technical content, delivering talks, and engaging with developer communities to promote the adoption of modern software …