A data structure is an organized collection of data. It is a unique format for storing data to serve a particular purpose. It is used to access the data and manage it easily. Data structures are a technological means of organizing and storing data in computers so that we can perform operations on the stored data more efficiently. Data structures have a broad and diverse scope of usage across Computer Science and Software Engineering fields.
Designed with developers in mind and unlike simplistic key-value data stores, Redis data structures deliver flexible ways to model your data for many use cases in modern applications. Redis sophisticated data structures enable you to develop applications with fewer lines of elegant code to store, access, and use your data and enable powerful and speedy in-memory processing.
These data structures avoid the overhead associated with translation between application objects to database entities for every database operation.
Redis Strings is one of the most versatile of Redis’ building blocks, a binary-safe data structure. Strings is an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. It can store any data-a string, integer, floating point value, JPEG image, serialized Ruby object, or anything else you want it to carry. Operate on a whole string or parts, and increment or decrement integers and floats.
Redis Sets data structure stores a unique set of members. With Sets, you can add, fetch, or remove members, check membership, or retrieve a random member. With the sorting algorithm, you can also perform set operations such as intersection, union, and set difference and compute set cardinality.
Redis Sorted Sets contain a unique set of members ordered by floating-point scores. As with Sets, you can add, fetch, or remove individual members and perform set operations such as union, intersection, set difference, and compute cardinality. Furthermore, you can also query the set based on score or member value, aggregate, filter, and order results.
Redis Lists holds collections of string elements sorted according to their order of insertion. Push or pop items from both ends, trim based on offsets, read individual or multiple items, or find or remove items by value and position. You can also make blocking calls for asynchronous message transfers.
A Redis hash is a data type that represents a mapping between a string field and a string value. Redis Hashes structure stores a set of field-value pairs designed not to take up much space, making them ideal for representing data objects. It provides the ability to add, fetch, or remove individual items, fetch the entire hash, or use one or more fields in the hash as a counter.
Redis Bitmaps is a compact data structure to store binary logic and states. It provides commands to fetch and set a bit value at a given position, and perform AND, OR, XOR, and NOT operations between multiple bitmap keys.
Bitfields offer an efficient, compact way to implement multiple counters in a single array. It allows incrementing and decrementing counters at a given position, and flags overflow when the counter reaches its upper limit.
Redis HyperLogLog is a probabilistic data structure used to count unique values (set cardinality) at a constant memory size. You can add and count a large number of unique items with memory efficiency, and merge two or more HyperLogLog data structures into one.
Geospatial indexes provide an extremely efficient and simple way to manage and use geospatial data in Redis. You can add unique items with latitude and longitude, compute the distance between objects, and find members within a given radius range from a location.
Redis Streams is an incredibly powerful data structure for managing high-velocity data streams (like a message queue). With out-of-the-box partitioning, replication, and persistence, it can capture and process millions of data points per second at sub-millisecond latency. Redis Streams is based on an efficient radix-tree implementation (an algorithm where each node that is the only child is merged with the parent), which makes the range and lookup queries extremely fast. It connects producers and consumers with asynchronous calls and supports consumer groups.