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

Ehcache

177
159
+ 1
4
Memcached

7.7K
5.5K
+ 1
473
Add tool

Ehcache vs Memcached: What are the differences?

Introduction

Ehcache and Memcached are both popular caching solutions used by developers to improve the performance and scalability of their applications. While they serve a similar purpose, there are key differences between the two.

  1. Architecture: Ehcache is an in-memory caching solution that can be used as a standalone cache or integrated with other frameworks. It stores data in the Java heap memory of the application. On the other hand, Memcached is a distributed caching system that stores data in a separate process or server, allowing it to be shared across multiple applications or servers.

  2. Data Persistence: Ehcache provides the option to persist cached data on disk or in a database. This allows data to be retained even after the application restarts. In contrast, Memcached does not provide built-in data persistence and relies on the principle of ephemeral caching, where data is temporary and not guaranteed to be available after a restart.

  3. Scalability: Memcached is designed for high scalability and can be easily deployed in a distributed manner. It supports a distributed hash table (DHT) algorithm for data partitioning and replication across multiple Memcached servers. In comparison, Ehcache is primarily designed for single-server deployments and does not have built-in support for distributed caching.

  4. API and Language Support: Ehcache is tightly integrated with the Java programming language and provides a comprehensive set of APIs for Java developers. It also offers support for some other JVM languages like Scala and Groovy. In contrast, Memcached has a language-agnostic API, making it accessible to developers using languages such as PHP, Python, Ruby, and more.

  5. Consistency and Synchronization: Ehcache provides strong consistency guarantees and supports synchronization mechanisms like locking and transactional caching. This ensures data integrity in multi-threaded or clustered environments. Memcached, on the other hand, does not provide built-in mechanisms for consistency and synchronization, as it primarily focuses on high-speed caching operations.

  6. Community and Ecosystem: Ehcache has a strong community support and is widely used in Java-based enterprise applications. It is actively maintained and backed by companies like Terracotta. Memcached also has a large community and is popular among developers working with web and distributed systems. It is open-source and has numerous client libraries available for various programming languages.

In Summary, Ehcache and Memcached differ in their architecture, data persistence, scalability, language support, consistency guarantees, and community/ecosystem. These differences make them suitable for different use cases and development environments.

Advice on Ehcache and Memcached
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 Memcached
  • 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
  • 139
    Fast object cache
  • 129
    High-performance
  • 91
    Stable
  • 65
    Mature
  • 33
    Distributed caching system
  • 11
    Improved response time and throughput
  • 3
    Great for caching HTML
  • 2
    Putta

Sign up to add or upvote prosMake informed product decisions

Cons of Ehcache
Cons of Memcached
    Be the first to leave a con
    • 2
      Only caches simple types

    Sign up to add or upvote consMake 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 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.

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

    What companies use Ehcache?
    What companies use Memcached?
    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 Memcached?
      No integrations found

      Sign up to get full access to all the tool integrationsMake informed product decisions

      Blog Posts

      Dec 22 2020 at 9:26PM

      Pinterest

      Amazon EC2C langMemcached+4
      10
      2681
      Jun 6 2019 at 5:11PM

      AppSignal

      RedisRubyKafka+9
      15
      1687
      GitHubDockerReact+17
      41
      37101
      GitHubPythonNode.js+47
      55
      72676
      JavaScriptGitHubNode.js+26
      20
      5010
      JavaScriptGitHubPython+42
      53
      22090
      What are some alternatives to Ehcache and Memcached?
      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.
      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.
      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