Redis Explained: Core Features, Advantages, and Comparison with Memcached
Redis is an open-source, in‑memory data structure store offering high‑performance caching, persistence, replication, and rich data types such as strings, lists, sets, hashes, and sorted sets, and this guide compares its strengths and differences with Memcached and other databases.
Redis Overview
Redis is an open-source in-memory data-structure store that can serve as a database, cache, and message broker.
It supports various data structures: strings, hashes, lists, sets, sorted sets (ZSet) with range queries, bitmaps, hyperloglogs, and geospatial indexes. The most common types are String, List, Set, Hash, and ZSet.
Redis includes built-in replication, Lua scripting, LRU eviction, transactions, and multiple persistence levels, and provides high availability via Sentinel and Cluster.
Persistence options allow data to be saved to disk either as snapshots or via an append-only file (AOF). Persistence can be disabled to use Redis purely as a fast cache.
Redis does not use tables; its database does not require predefined schemas or relationships.
Database operation modes are divided into disk-based and memory-based databases. Redis stores data in memory, eliminating disk I/O bottlenecks and delivering extremely fast read/write performance.
Redis Advantages
High performance – up to 110,000 reads/s and 81,000 writes/s.
Rich data types – supports binary-safe Strings, Lists, Hashes, Sets, and Ordered Sets.
Atomic operations – all commands are atomic, and multi-command transactions are also atomic.
Feature-rich – includes publish/subscribe, notifications, key expiration, etc.
Key Differences from Memcached
Both Redis and Memcached are in-memory key-value stores, but Redis offers many more data structures (list, set, zset, hash) while Memcached only stores plain string values.
Memcached appends data using the APPEND command and hides deleted elements via a blacklist, whereas Redis allows direct addition and removal of elements in Lists and Sets.
Additional differences include:
Both store data in memory, but Memcached can also cache other objects such as images or videos.
Redis provides virtual memory, swapping rarely used values to disk when physical memory is exhausted.
Expiration: Memcached sets expiration at the set command (e.g., set key1 0 0 8 never expires), while Redis uses the expire command (e.g., expire name 10).
Distribution: Memcached clusters use a client‑side hashing scheme; Redis supports master‑slave replication and clustering.
Data safety: Memcached loses data on crash; Redis can persist data to disk.
Disaster recovery: Redis can recover data via AOF; Memcached cannot.
Backup: Redis supports master‑slave backups.
Use cases: Redis serves as a NoSQL database, message queue, data stack, and cache; Memcached is mainly for caching SQL results, session data, and temporary objects.
Resources
Official website: https://redis.io/
Chinese site: http://www.redis.cn/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
