Use Cases

Memcached Upgrade

Use Hazelcast as a drop-in replacement for Memcached, with the added benefits of elastic scaling (much larger cache sizes), ultra-fast performance, high availability, and easy maintenance. No changes are required in your apps/clients to upgrade to Hazelcast other than pointing to the Hazelcast cluster. Hazelcast has been used in production as an alternative to Memcached as well as a plug-in enhancement.

Solution: Replacing Memcached with Hazelcast is easy

To replace Memcached with Hazelcast you only need to point your Memcached code to your Hazelcast cluster. No additional code or configuration changes are needed. To walk through an example:

Let’s say your cluster’s members are:

Members [5] {
Member []
Member []
Member []
Member []
Member []

And you have a PHP application that uses PHP Memcache client to cache things in Hazelcast. All you need to do is have your PHP Memcache client connect to one of these members. It doesn’t matter which member the client connects to because Hazelcast a cluster looks like one giant machine (Single System Image). PHP client code sample:

$get_result = $memcache->get('key1'); //retrieve your data
var_dump($get_result); //show it

Notice that Memcache client is connecting to and using port 5701. Java client code sample with SpyMemcached client:

MemcachedClient client = new MemcachedClient(AddrUtil.getAddresses(""));
client.set("key1", 3600, "value1");

An entry written with a Memcache client can be read by another Memcache client written in another language.

Advantages of Using Hazelcast Instead of Memcached

Elastic Clustering

Add more nodes (or remove nodes) without touching your clients and increase or decrease cluster capacity on demand.

Flexibility for Developers

Go beyond Memcached and write smarter apps by using listeners, locks and more. Hazelcast APIs are very similar to JDK’s, which makes it easier for developers to easily understand the technology and develop robust and scalable applications with minimal code changes and development efforts.

More than Just Caching

Hazelcast is a complete IMDG solution that, along with distributed caching, provides features for in-memory distributed computing and messaging. Hazelcast supports many data structures such as Queue, Topic, Distributed ExecutorService, EntryProcessor, Distributed RingBuffer, ReliableTopic, etc.


Memcached has only one copy of each object at one node whereas Hazelcast allows you to have up to 6 copies for each entry. This allows you to configure higher levels of availability. Replication in a Memcached cluster relies on using external libraries and deployment for replication (Repcached).

Smart Clients

Client nodes (application nodes) connect with all the server members to send/receive requests/responses as opposed to Memcached where all the requests from a client are routed through a particular server member. This makes server members a bottleneck in cases of large concurrent transactions.


Data is never lost in a Hazelcast cluster, whether a node leaves or joins the cluster or the cluster faces a split brain scenario. A Memcached cluster is likely to lose data when a node leaves the cluster for a short while and come back in (all the updates are lost during this time).