Setting up Redis

Redis is a popular NoSQL in-memory database. Since the entire database is present in the memory, database queries are blazingly fast. Redis is also known to offer support for a robust variety of data types, and it's a multipurpose tool that can be used as a database, a memory-cache, or even as a message broker.

In this book, we will use Redis for IGWEB's data persistence needs. We will be running our Redis instance on the default port of 6379.

We issue the following commands to download and install Redis:

$ wget http://download.redis.io/releases/redis-4.0.2.tar.gz
$ tar xzf redis-4.0.2.tar.gz
$ cd redis-4.0.2
$ make
$ sudo make install

An alternative to fetching Redis using the wget command is to obtain it from the Redis Downloads page, as shown in Figure 2.7, at https://redis.io/download:

Figure 2.7: The Downloads section on the Redis website

Once you have downloaded and installed Redis, you can start up the server by issuing the redis-server command:

$ redis-server

In another Terminal window, we can open up the Redis command-line interface (CLI), to connect to the Redis server instance, using the redis-cli command:

$ redis-cli

We can set a foo key with the bar value using the set command:

127.0.0.1:6379> set foo bar
OK

We can get the value for the foo key using the get command:

127.0.0.1:6379> get foo
"bar"

You can learn more about Redis by visiting the documentation section of the Redis website at https://redis.io/documentation. Going through the Redis quick start document available at https://redis.io/topics/quickstart is also helpful. Now that we've installed our local Redis instance, it's time to build and run the IGWEB demo.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.154.252