I. What Redis
REMoteDICtionarySErver (Redis for short) is a Key-Value storage system similar to Memcached. Compared with Memcached, Memcached supports richer data structures, including string, list, set, and zset) and hash (hash type), and provides a data persistence mechanism. In some scenarios, you can use it as a non-relational database. It is a high-performance storage system that supports read/write frequencies of over 100 K + per second. It also supports message publishing/subscription, so that you have another option when building a high-performance Message Queue System.
Ii. Download
Click here to download.
I downloaded the redis-3.0.0-beta5 version here and redis started to support clusters from 3.0.
Iii. Installation
The following installation steps are performed on the OSX operating system:
1. Find the redis-3.0.0-beta5.tar.gz file you just downloaded and unzip it.
2. Copy the decompressed folder to a directory that you can easily find and change the folder name to redis because the version number is too long.
2. Open the terminal and enter the redis folder. The command is as follows:
Last login: Fri May 30 21:33:25 on ttys000
Zhaoguihuadediannao :~ Zhaogh $ cd applications/dev/redis
Zhaoguihuadediannao: redis zhaogh $
3. Enter the make command at the command prompt. Wait a moment to complete the installation. If the system prompts that the make command cannot be found, refer to this article.
It's a little excited. Smoke a cigarette. Let's continue.
Iv. Use
1. Start the service, first enter the src directory, and then execute redis-server.
Zhaoguihuadediannao: redis zhaogh $ cd src
Zhaoguihuadediannao: src zhaogh $./redis-server
You will see:
2343: M 30 May 21:42:50. 741 # Server started, Redis version 2.9.54
2343: M 30 May 21:42:50. 741 * The server is now ready to accept connections on port 6379
I'm not mistaken, right? tmd I obviously downloaded 3.0.0. How can I display Redis version 2.9.54? Well, this is not the point, and I am too lazy to pursue it.
6379 is the default port of apsaradb for redis. You will know how to modify this default port in subsequent articles.
2. Client connection.
You will find that after Step 4 is executed, we cannot execute other commands. What should we do? Because redis excludes this process, we will tell you how to modify it to run in the background.
Now let's open another terminal. Go to the src directory first:
Zhaoguihuadediannao :~ Zhaogh $ cd applications/dev/redis/src
Zhaoguihuadediannao: src zhaogh $
Enter the./redis-cli command:
Zhaoguihuadediannao: src zhaogh $./redis-cli
Wagner. 0.0.1: 6379>
Already connected, hahaha.
3. test several redis commands:
127.0.0.1: 6379> set testkey001 testkey001
OK
127.0.0.1: 6379> get testkey001
"Testkey001"
Wagner. 0.0.1: 6379> append testkey001 aaa
(Integer) 13
127.0.0.1: 6379> get testkey001
"Testkey001aaa"
Wagner. 0.0.1: 6379>
4. Close the connection and run the quit command.
127.0.0.1: 6379> quit
Zhaoguihuadediannao: src zhaogh $
5. Close the service.
Since we have exited the client just now, we connect again and execute the shutdown command:
Wagner. 0.0.1: 6379> shutdown
Wagner. 0.0.1: 6379>
Check whether [the process has been completed] is displayed in another terminal window. You can also use the kill command to close the service.
So much will be introduced today. The next article will show you how to use the c # client API to operate redis.