Redis installation and basic data types
This article describes the Redis installation and basic data types. Xiaobian thinks it's quite good. Interested friends can refer to it. The details are as follows
Installation 1. Alibaba Cloud CentOS
1. Enter centos system, enter wget, download the latest version of Redis, download process as shown below.
2. Unzip the downloaded file and enter it into the unzipped directory.
3. Enter make to compile.
4. Go to src directory and copy redis-server,redis-benchmark,redis-cli to a directory you created.
5. Set environment variables.
The copy code is as follows: vi /etc/profile
Add export PATH=/usr/local/liuyang/redis:$PATH at the end
Directory needs to be modified to own directory
Enter source /etc/profile
6. Start the Redis service by typing redis-server.
7. Open another terminal and type redis-cli to test it.
2.Windows
1. Go to https://github.com/MSOpenTech/redis/releases
2. Download the zip package and unzip it.
3. Open a console, cd to the unzipped directory, and run redis.server.
4. Open another console and run redis.cli under the decompression directory to perform the basic operations of Redis.
Redis data type
String Add: Add by setting key value.
Get: Get key.
Deletion: Deletion by del key.
2.Add to List:
push key value: Insert an element at the end.
lpush key value: Insert an element into the header. Get:
lrange key 0 -1: 0 represents the first element,-1 represents the penultimate element.
3.Hash
Add: hmset key hashtable
Get: hget key hashtable.key
hgetall key
4. disordered Set
Add: sadd key value1 value2...
Get: smembers sadd
5. Ordered Set
Add: zadd key sortArguments value
sortArgument: Parameter used for sorting
Get:
Positive sequence: zrange key 0 -1
Reverse order: zrevrange key 0 -1
The above is the whole content of this article, I hope the content of this article has a certain reference value for everyone's study or work, if you have questions, you can leave a message to exchange, thank you for your support.