Book Image

Learning Redis

By : Vinoo Das
Book Image

Learning Redis

By: Vinoo Das

Overview of this book

Table of Contents (16 chapters)
Learning Redis
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Hello World in Redis


This section will excite programmers the most. Let's get our hands dirty and punch in some code. But, before that, we have to understand that Redis works on a client-server model and uses the Redis protocol to communicate with the server. For the client to connect to the server, the client has to know the location of the server. For this section, I am going to show samples using the redis-cli and Java clients.

Hello World using redis-cli

Start the Redis client Command Prompt (make sure that the server is running). Type in the following commands, as shown in the following screenshot, and see the outcome:

Trying simple Set and Get commands using the Redis client

There are three parts to the command we wrote. They are explained as follows:

  • Set: This command is used to set a value in the Redis server

  • MSG: This is the key for the message to be stored in the Redis server

  • Hello World: This is the value stored in the server for the MSG key

So, this clears a pattern that we have to...