One, data type string--string
The simplest type,
Can be understood as the same type as memcached so the memcached inside can be transferred intact to Redis inside the Redis can store binary objects---than slices, and so on.
//alias First, then redis to connect[[email protected] ~]# alias redis-cli='/usr/local/redis/bin/redis-cli'[[Email protected]~]# redis-CLI127.0.0.1:6379>SetKey1 Luluok127.0.0.1:6379>GetKey1"Lulu"127.0.0.1:6379> Mset key1 lulu key2 ff Key3 ll//assigning values to multiple variables MsetOK127.0.0.1:6379> Mget key1 key2 Key3//get multiple variables mget1)"Lulu"2)"FF"3)"ll"127.0.0.1:6379> (crtl+D exit)//you can get the value directly with the command[Email protected] ~]# REDIS-CLIGetKey2"FF"
Data Type list-similar pipe, or table, can insert data
Linked list structure
[Email protected] ~]# redis-CLI127.0.0.1:6379> Lpush List1123 //insert data from the left(integer)1127.0.0.1:6379>lpush list1 aaa (integer)2127.0.0.1:6379>lpush list1 ml (integer)3127.0.0.1:6379> Rpop List1//fetch data from the right"123"127.0.0.1:6379> Lrange List10-11)"ml"2)"ABC"3)"AAA" //regularity1first inserted, run to the last side2. Can be inserted from the left, the first inserted, will go to the far right--You have to take it from the right.3. Can be inserted from the right, first inserted, will go to the far left--You have to take lrange from the left List10-1{Lists the values at the specified position in the table, only Lrange, no rrange}0 represents the leftmost first 1 represents the rightmost first one
Third, data type set---set
[Email protected] ~]# redis-CLI127.0.0.1:6379> Sadd SET1 ABC//Set1 is the name of the collection, which is the addition of elements to the collection(integer)1127.0.0.1:6379>sadd set1 defg (integer)1127.0.0.1:6379>sadd set1 Hijk (integer)1127.0.0.1:6379> Smembers Set1//gets the value in the collection1)"DEFG"2)"ABC"3)"Hijk"//Positive Order Join value:127.0.0.1:6379> ZaddSet 2nnn//2 for the arranged position(integer)1127.0.0.1:6379> ZaddSet 1kll (integer)1127.0.0.1:6379> ZaddSet 3EFG (integer)1127.0.0.1:6379> ZrangeSet 0-11)"Kll"2)"nnn"3)"EFG"//to display the inserted data in reverse:127.0.0.1:6379> ZrevrangeSet 0-11)"EFG"2)"nnn"3)"Kll"
Four, data type hash
[Email protected] ~]# redis-CLI127.0.0.1:6379>Hset Hash name Lulu (integer)1127.0.0.1:6379> Hset Hash Age A(integer)1127.0.0.1:6379>hset hash Sex womam (integer)1127.0.0.1:6379> Hgetall Hash//get all the data1)"name"2)"Lulu"3)" Age"4)" A"5)"Sex"6)"Womam"127.0.0.1:6379> Hget Hash Age//take the data of one of the variables" A"
Redis data types