Open anitsh opened 3 years ago
An in-memory key-value data store for use as a database, cache, message broker, and queue.
All Redis data resides in-memory, in contrast to databases that store data on disk or SSDs. By eliminating the need to access disks, in-memory data stores such as Redis avoid seek time delays and can access data in microseconds. Redis features versatile data structures, high availability, geospatial, Lua scripting, transactions, on-disk persistence, and cluster support making it simpler to build real-time internet scale apps. It works with relational or key-value databases to improve performance, such as MySQL, Postgres, Aurora, Oracle, SQL Server, DynamoDB, and more.
Unlike simplistic key-value data stores that offer limited data structures, Redis has a vast variety of data structures:
Use Cases: Caching, Chat, messaging, and queues, Gaming leaderboards, Session store, Rich media streaming, Geospatial, Machine Learning, Real-time analytics
Language: Python, Java, PHP, C/C#/C++, Perl, Go, Ruby, JavaScript, Node.js
Name | Type | Data storage options | Query types | Additional features |
---|---|---|---|---|
Redis | In-memory non-relational database | Strings, lists, sets, hashes, sorted sets | Commands for each data type for common access patterns, with bulk operations, and partial transaction support | Publish/Subscribe, master/slave replication, disk persistence, scripting (stored procedures) |
memcached | In-memory key-value cache | Mapping of keys to values | Commands for create, read, update, delete, and a few others | Multithreaded server for additional performance |
MySQL | Relational database | Databases of tables of rows, views over tables, spatial and third-party extensions | SELECT, INSERT, UPDATE, DELETE, functions, stored procedures | ACID compliant (with InnoDB), master/slave and master/master replication |
PostgreSQL | Relational database | Databases of tables of rows, views over tables, spatial and third-party extensions, customizable types | SELECT, INSERT, UPDATE, DELETE, built-in functions, custom stored procedures | ACID compliant, master/slave replication, multi-master replication (third party) |
MongoDB | On-disk non-relational document store | Databases of tables of schema-less BSON documents | Commands for create, read, update, delete, conditional queries, and more | Supports map-reduce operations, master/slave replication, sharding, spatial indexes |
Memcached has simpler use cases as it has fewer features. Primarily used for cache and session storage.
Language/Protocol Support: Python, Java, PHP, C/C#/C++, Perl, Go, Ruby, JavaScript, Node.js, ASCII protocol, Binary protocol, TCP & UDP protocols
Feature | Memcached | Redis |
---|---|---|
Sub-millisecond latency | Yes | Yes |
Developer ease of use | Yes | Yes |
Data partitioning | Yes | Yes |
Support for a broad set of programming languages | Yes | Yes |
Advanced data structures | - | Yes |
Multithreaded architecture | Yes | - |
Snapshots | - | Yes |
Replication | - | Yes |
Transactions | - | Yes |
Pub/Sub | - | Yes |
Lua scripting | - | Yes |
Geospatial support | - | Yes |
Sub-millisecond latency Both Redis and Memcached support sub-millisecond response times. By storing data in-memory they can read data more quickly than disk based databases.
Developer ease of use Both Redis and Memcached are syntactically easy to use and require a minimal amount of code to integrate into your application.
Data partitioning Both Redis and Memcached allow you to distribute your data among multiple nodes. This allows you to scale out to better handle more data when demand grows.
Support for a broad set of programming languages Both Redis and Memcached have many open-source clients available for developers. Supported languages include Java, Python, PHP, C, C++, C#, JavaScript, Node.js, Ruby, Go and many others.
Advanced data structures In addition to strings, Redis supports lists, sets, sorted sets, hashes, bit arrays, and hyperloglogs. Applications can use these more advanced data structures to support a variety of use cases. For example, you can use Redis Sorted Sets to easily implement a game leaderboard that keeps a list of players sorted by their rank.
Multithreaded architecture Since Memcached is multithreaded, it can make use of multiple processing cores. This means that you can handle more operations by scaling up compute capacity.
Snapshots With Redis you can keep your data on disk with a point in time snapshot which can be used for archiving or recovery.
Replication Redis lets you create multiple replicas of a Redis primary. This allows you to scale database reads and to have highly available clusters.
Transactions Redis supports transactions which let you execute a group of commands as an isolated and atomic operation.
Pub/Sub Redis supports Pub/Sub messaging with pattern matching which you can use for high performance chat rooms, real-time comment streams, social media feeds, and server intercommunication.
Lua scripting Redis allows you to execute transactional Lua scripts. Scripts can help you boost performance and simplify your application.
Geospatial support Redis has purpose-built commands for working with real-time geospatial data at scale. You can perform operations like finding the distance between two elements (for example people or places) and finding all elements within a given distance of a point.
Keeps data in the memory!
Basic Features