Need advice about which tool to choose?Ask the StackShare community!

Ehcache

178
159
+ 1
4
guava

1.2K
193
+ 1
6
Add tool

Ehcache vs guava: What are the differences?

Introduction

This article discusses the key differences between Ehcache and Guava, two popular caching libraries used in software development.

  1. In-Memory Caching vs Caching Utilities:

    • Ehcache is primarily an in-memory caching library that allows developers to store and retrieve data in memory for fast access. On the other hand, Guava is a general-purpose caching utility library that provides caching functionality along with other utility classes.
  2. Cache Eviction Policies:

    • Ehcache offers a wide range of cache eviction policies such as LRU (Least Recently Used), LFU (Least Frequently Used), and FIFO (First In, First Out). These policies determine which cache entries to remove when the cache reaches its maximum capacity. In contrast, Guava's caching utilities use a simpler eviction policy based on the size of the cache and a combination of time-based and reference-based cache eviction.
  3. Distributed Caching Support:

    • Ehcache provides built-in support for distributed caching, allowing multiple instances of an application to share a common cache. On the other hand, Guava does not offer native support for distributed caching and is primarily designed for single-instance caching scenarios.
  4. Cache Loading Strategies:

    • Ehcache supports various cache loading strategies such as manual loading, lazy loading, and asynchronous loading. These strategies dictate when and how cache entries are loaded into the cache. In contrast, Guava does not provide built-in support for cache loading strategies and requires developers to manually load cache entries.
  5. Integration with Java EE Standards:

    • Ehcache is integrated with Java EE standards and can be easily used in Java EE applications. It supports features such as caching annotations, declarative configuration, and integration with Java EE frameworks. On the other hand, Guava is a standalone library and does not have direct integration with Java EE standards.
  6. Cache Statistics and Monitoring:

    • Ehcache provides extensive cache statistics and monitoring features, allowing developers to gain insights into the cache's performance, hit/miss ratio, and memory usage. Guava, on the other hand, provides limited cache statistics functionality and lacks detailed monitoring features.

In summary, Ehcache is primarily an in-memory caching library with distributed caching support, various cache eviction policies, cache loading strategies, and integration with Java EE standards. Guava, on the other hand, is a general-purpose caching utility library with a simpler cache eviction policy, no native distributed caching support, no built-in cache loading strategies, and limited cache statistics and monitoring features.

Advice on Ehcache and guava
Francisco José Casasaltas Perales
Needs advice
on
EhcacheEhcacheguavaguava
and
MemcachedMemcached

Hi guys! I need an in-memory key/value storage with a lifespan for each key What do you recommend me to use? I was thinking about using a ConcurrentHashMap, with a scheduled thread evicting keys when apply. In fact, it is a possibility due because the performance is not important. But, on the other side, I have considered using any library such as Memcached, Ehcache, guava...

See more
Replies (1)
Recommends
on
RedisRedis

Redis can do the same jobs as Memcached, ECache or any other im-memory caching tool and can do them better. - Redis can act as a cache as well. It can store key/value pairs too. In Redis, they can even be up to 512MB. - Redis is better documented than Memcached and ECached. - Supports many data types. (Strings, Hashes, Lists, Sets, Sorted Sets, Geo, Bitmap and HyperLogLog) - Redis provides pub/sub as well. - Redis can be scaled easily horizontally if needed using its own tool Redis Sentinel. - Wide variety of client libraries in almost every language.

See more
Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of Ehcache
Pros of guava
  • 1
    Way Faster than Redis and Elasticache Redis
  • 1
    Easy setup
  • 1
    Simpler to run in testing environment
  • 1
    Container doesn't have to be running for local tests
  • 5
    Interface Driven API
  • 1
    Easy to setup

Sign up to add or upvote prosMake informed product decisions

What is Ehcache?

Ehcache is an open source, standards-based cache for boosting performance, offloading your database, and simplifying scalability. It's the most widely-used Java-based cache because it's robust, proven, and full-featured. Ehcache scales from in-process, with one or more nodes, all the way to mixed in-process/out-of-process configurations with terabyte-sized caches.

What is guava?

The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.

Need advice about which tool to choose?Ask the StackShare community!

What companies use Ehcache?
What companies use guava?
Manage your open source components, licenses, and vulnerabilities
Learn More

Sign up to get full access to all the companiesMake informed product decisions

What tools integrate with Ehcache?
What tools integrate with guava?
    No integrations found

    Blog Posts

    What are some alternatives to Ehcache and guava?
    Memcached
    Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
    Apache Ignite
    It is a memory-centric distributed database, caching, and processing platform for transactional, analytical, and streaming workloads delivering in-memory speeds at petabyte scale
    Hazelcast
    With its various distributed data structures, distributed caching capabilities, elastic nature, memcache support, integration with Spring and Hibernate and more importantly with so many happy users, Hazelcast is feature-rich, enterprise-ready and developer-friendly in-memory data grid solution.
    Redis
    Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.
    MySQL
    The MySQL software delivers a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server. MySQL Server is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.
    See all alternatives