The previous chapter dealt with installation of Redis and running some simple programs. Since Redis is a datastore, so it's important to understand how Redis treats data by providing data structures to handle and store them. Also important is how Redis deals with data while communicating it to a client such as the communication protocol.
You're reading from Learning Redis
Data structure, as the word suggests, means a structure for storing data. In the world of computing, data is always organized in a way that makes sense to the program storing it. Data structure can vary from a simple sequential arrangement of characters to a complex map where keys are not arranged sequentially, but on the basis of an algorithm. Data structures are often composite in nature, which means that one data structure can hold other data structure, which is a map holding another map.
The key influencing factors in designing a data structure are performance and memory management of the data structure. Some of the common examples of data structures are lists, sets, maps, graphs and trees, tuples, and so on. As programmers, we have used data structures in our programs time and again. In an object-oriented world, a simple object is also a data structure since it contains data, and logic to access those data. Every data structure is governed by an algorithm which decides...
Redis, a data structure server has many in-built data types, which makes it a bit different from other key-value NoSQL datastores in the ecosystem. Unlike other NoSQL, Redis provides the users with many in-built data types which provide a sematic way of arranging their data. Think of it like this; while designing a solution we need domain objects which in a way shape up our data layer. After deciding on the domain objects, we need to design the structure for our data that will be saved in the data store for which we need some predefined data structures. The advantage of this is that it saves time and efforts of the programmers to externally create and manage this data. For example, suppose in our program there is a requirement for a Set like data structure. Using Java, we can easily use an in-built data structure such as Set. If we were to put this data as a key-value, we will have to put the entire set against a key. Now if we were to sort this Set, the normal way would...
Redis in principle works on a client-server model. So like in every client-server model, the client and the server need to have a protocol to communicate with. Communication protocol can be understood as a message exchange taking place between client and the server (and vice versa) based on some fixed agreement or rule between them. So every communication protocol has to adhere to some syntax and semantics, which should be followed by both the parties (client and server) for the communication to be successful. There is also another dimension to this communication protocol, which is the network layer interaction, or better known as TCP/IP Model. The TCP/IP Model can be divided into four parts:
Application layer
Transport layer
Internet layer
Network interface
Since the communication protocol between two applications is at application layer, so we intend to focus only on the application layer. The following diagram is a representation of what happens in the communication...
In this chapter, we brushed with various data structures or data types which Redis provides. We also wrote a few programs to see them working and made an attempt to understand how and where these data types can be used. Finally, we understood how Redis communicates with the clients and vice versa.
In the next chapter, we will take our understanding a notch higher and make an attempt to understand Redis Server and the functionality that'll handle it.