Redis
Redis is an open-source, in-memory data structure store, often used as a database, cache, and message broker, distinguished by its support for diverse data type...
Redis (Remote Dictionary Server) is an open-source, in-memory data structure store, used as a database, cache, and message broker. It supports various data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries, and streams. Redis is renowned for its speed, as it primarily operates in memory, allowing for sub-millisecond latency for read and write operations. Its persistence can be configured through different mechanisms: Snapshotting (RDB), which saves point-in-time snapshots of the dataset, and Append Only File (AOF), which logs every write operation received by the server. Redis also offers high availability and fault tolerance through Redis Sentinel, which provides monitoring, notification, and automatic failover, and Redis Cluster, which provides a way to run a Redis installation where data is sharded across multiple nodes, offering horizontal scalability and high availability. Its publish/subscribe capabilities make it suitable for real-time messaging systems and event-driven architectures. Redis is widely adopted for use cases like session management, real-time leaderboards, caching frequently accessed data, and message queuing.
graph LR
Center["Redis"]:::main
Pre_nosql["nosql"]:::pre --> Center
click Pre_nosql "/terms/nosql"
Rel_cache["cache"]:::related -.-> Center
click Rel_cache "/terms/cache"
Rel_nginx["nginx"]:::related -.-> Center
click Rel_nginx "/terms/nginx"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 Explícalo como si tuviera 5 años
Es como un tablero de notas adhesivas digitales súper rápido donde puedes escribir y encontrar información rápidamente, manteniendo las notas más importantes justo delante de ti.
🤓 Expert Deep Dive
Redis's performance is largely attributed to its single-threaded, event-driven architecture, which efficiently handles I/O multiplexing using mechanisms like epoll or kqueue. While the core operations are single-threaded to ensure atomicity and simplify development, background threads handle I/O and slow operations like disk persistence. Data structures are optimized for in-memory access; for example, hashes are implemented as hash tables, and sorted sets use a combination of hash tables and skip lists. The RDB persistence mechanism involves forking the main process, which can be I/O intensive but provides a compact snapshot. AOF persistence, while more durable, can lead to larger files and slower restarts. Redis Sentinel provides high availability by monitoring master and replica nodes and orchestrating failover. Redis Cluster shards data across multiple nodes, distributing keyspace and providing resilience against node failures, though it introduces complexity in managing distributed transactions and cross-slot operations. Security considerations include network access control (e.g., firewalls, ACLs) and authentication mechanisms.