Need advice about which tool to choose?Ask the StackShare community!
Memcached vs Redis vs guava: What are the differences?
Key Differences between Memcached and Redis and Guava
Memcached and Redis are both popular in-memory data stores that are commonly used for caching and improving the performance of web applications. Guava, on the other hand, is a Java library that provides various utility classes and functions. While all three have caching capabilities, there are some key differences between them.
Data Structure Support: Redis and Guava provide more extensive data structure support compared to Memcached. Redis includes data structures such as strings, hashes, lists, sets, and sorted sets, making it more suitable for complex data manipulation. Guava, on the other hand, offers data structures like collections, caching, and functional types that are highly efficient.
Persistence: Redis has built-in persistence options, allowing data to be stored on disk and loaded back into memory upon restart. This feature makes Redis more suitable for use cases that require persistence and data durability. Memcached, on the other hand, does not provide built-in persistence and is generally used for caching purposes only. Guava does not offer persistence as it is mainly focused on providing utility functions.
Scalability: Redis and Memcached are designed to be highly scalable and can be easily scaled horizontally by adding more servers to the cache cluster. Memcached is a distributed cache that allows data to be spread across multiple nodes, while Redis supports replication and sharding for scalability. Guava, being a Java library, does not provide built-in scalability features and is limited by the resources of a single Java Virtual Machine (JVM).
Support for Multiple Programming Languages: Memcached and Redis are both designed to support multiple programming languages and can be accessed from various application frameworks. Redis supports clients for different programming languages, including Java, C++, Python, and more. Guava, being a Java library, is primarily targeted for Java developers and does not have direct support for other programming languages.
Cache Eviction Policies: Redis and Guava both provide flexible cache eviction policies, allowing control over how data is evicted from the cache in case it becomes full. Redis offers a variety of eviction options, including LRU (Least Recently Used), LFU (Least Frequently Used), and more. Guava also provides different eviction policies like LRU, LFU, and size-based eviction. Memcached, however, does not provide built-in eviction policies and relies on application logic to manage cache eviction.
Additional Features: Redis provides additional features such as pub/sub messaging, transactions, and Lua scripting, making it more suitable for use cases requiring real-time messaging and atomic operations. Guava, being a utility library, offers various additional features like functional programming support, string manipulation utilities, and concurrency primitives.
In Summary, Memcached and Redis are powerful in-memory data stores with key differences in data structure support, persistence, scalability, programming language support, cache eviction policies, and additional features. Guava, on the other hand, is a Java library focused on providing utility classes and functions.
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...
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.
The obvious volatile memory choices were either Memcached or Redis. We eventually sided with Redis as it natively handled replication, and this replication fell under the PCI responsibility scope of AWS. This added duribility meant that if a redis node were to die, our downtime would be in the seconds, rather than 15 minutes which we would incur using Memcached
The requirement was the classic "cache the results of a SQL query for a period of time."
While the Internet is full of "Redis is fuller featured" posts, the key issue for us was the actual performance. We discovered, in various stress scenario testing, that Memcached outperformed Redis for simple key-value retrieval dramatically (over twice as fast.) That's not to say that Redis is bad - we use that in other places where the requirements are more sophisticated than simple key/value retrieval.
Pros of guava
- Interface Driven API5
- Easy to setup1
Pros of Memcached
- Fast object cache139
- High-performance129
- Stable91
- Mature65
- Distributed caching system33
- Improved response time and throughput11
- Great for caching HTML3
- Putta2
Pros of Redis
- Performance887
- Super fast542
- Ease of use514
- In-memory cache444
- Advanced key-value cache324
- Open source194
- Easy to deploy182
- Stable165
- Free156
- Fast121
- High-Performance42
- High Availability40
- Data Structures35
- Very Scalable32
- Replication24
- Pub/Sub23
- Great community22
- "NoSQL" key-value data store19
- Hashes16
- Sets13
- Sorted Sets11
- Lists10
- NoSQL10
- Async replication9
- BSD licensed9
- Integrates super easy with Sidekiq for Rails background8
- Bitmaps8
- Open Source7
- Keys with a limited time-to-live7
- Lua scripting6
- Strings6
- Awesomeness for Free5
- Hyperloglogs5
- Runs server side LUA4
- Transactions4
- Networked4
- Outstanding performance4
- Feature Rich4
- Written in ANSI C4
- LRU eviction of keys4
- Data structure server3
- Performance & ease of use3
- Temporarily kept on disk2
- Dont save data if no subscribers are found2
- Automatic failover2
- Easy to use2
- Scalable2
- Channels concept2
- Object [key/value] size each 500 MB2
- Existing Laravel Integration2
- Simple2
Sign up to add or upvote prosMake informed product decisions
Cons of guava
Cons of Memcached
- Only caches simple types2
Cons of Redis
- Cannot query objects directly15
- No secondary indexes for non-numeric data types3
- No WAL1