Memcached: Memcached is a distributed memory caching system which speeds up cloud based systems running on multiple servers.
Using memcached, Danga Interactive vastly improved the performance of LiveJournal.com whose load was crossing 20 million+ dynamic page views a day.
It exhibits LRU (Least Recently Used) behavior such that when then cache is full,
older data is removed from the cache.
Behavior: Memcached is organized as a group of servers whose cache is used by a group of clients.
Algorithm: Every client has a hashing algorithm to select the server first.
Once a server is selected, the client sends key-value pair to the server for cache storage.
The server then computes hash for the key to store the same in its cache.
All clients usually have the same server selecting hash-algorithm so that key-values stored by one client are accessible to all the other clients.
Ehcache: Ehcache is a Java distributed memory caching system.
It has a pluggable cache replication scheme which enables the addition of cache replication mechanisms as required by the application.
RMI, JMS, JGroups and Cache Server are fully supported by Ehcache to implement the replication scheme.
Cache replication is required during put, remove and update operations.
While put and remove are simple to achieve, update operation can be supported by updateViaCopy or updateViaInvalidate.
updateViaCopy: This replication mechanism send the entire key-value pair to all Ehcache servers for updation. updateViaInvalidate: In this mechanism, the updated server sends only a remove command for the changed key-value pair.
When other Ehcache servers remove the stale entries, the refreshed entry is automatically re-loaded from the data-source upon request.
This is somewhat more efficient as fully updated key-value pairs are not sent back-forth among the servers.
Got a thought to share or found a bug in the code? We'd love to hear from you: