Happy smile the tortoise was hurt. Let snails buy medicine. It took two hours. Snail bait hasn't returned yet. The tortoise shouted in a hurry: I will die if I don't come back! At this moment, the sound of a snail shell came out outside the door: You must say that I am not going! Question: What are the simple add, delete, modify, and query commands for five data types in Redis ??? Solve the problem. Assume that you have installed the Redis server.
Happy smile the tortoise was hurt. Let snails buy medicine. It took two hours. Snail bait hasn't returned yet. The tortoise shouted in a hurry: I will die if I don't come back! At this moment, the sound of a snail shell came out outside the door: You must say that I am not going! Question: What are the simple add, delete, modify, and query commands for five data types in Redis ??? Solve the problem. Assume that you have installed the Redis server.
Smile
The tortoise was injured. Let snails buy medicine. It took two hours. Snail bait hasn't returned yet. The tortoise shouted in a hurry: I will die if I don't come back! At this moment, the sound of a snail shell came out outside the door: You must say that I am not going!
Raise Questions
Simple addition, deletion, modification, and query commands for five Data Types of Redis ???
Solve the problem
Suppose you have installed the Redis server;
Suppose you have enabled the Redis cli command line tool;
Suppose you know something about Redis;
Example of simple addition, deletion, modification, and query of Redis
Example 1: add, delete, modify, and query strings
# Add a value 127.0.0.1: 6379> set ay_key "ay" OK # query the value of ay_key 127.0.0.1: 6379> get ay_key "ay" # modify the value of ay_key 127.0.0.1: 6379> set ay_key "new_ay" OK127.0.0.1: 6379> get ay_key "new_ay" # modify the ay_key name 127.0.0.1: 6379> rename ay_key new_ay_keyOK127.0.0.1: 6379> keys * 1) "new_ay_key" # Delete ay_key127.0.0.1: 6379> del ay_key (integer) 0 # query whether ay_key 0127.0.0.1: 6379> exists ay_key (integer) 0 exists
Example 2: add, delete, modify, and query a Set
# Delete All key127.0.0.1: 6379> flushdbOK in the selected database # generate the set and add four data 127.0.0.1: 6379> sadd set_ay_key "ay" "al" "xy" "xl" (integer) 4 # query all values in the set: 127.0.0.1: 6379> smembers set_ay_key1) "xy" 2) "al" 3) "ay" 4) "xl" # Delete value as "xl", return 1 if no return 0127.0.0.1: 6379> srem set_ay_key "xl" (integer) 1127.0.0.1: 6379> smembers set_ay_key1) "xy" 2) "al" 3) "ay" # add value to "xl" 127.0.0.1: 6379> sadd set_ay_key "xl" (integer) 1127.0.0.1: 6379> smembers set_ay_key1) "xy" 2) "al" 3) "ay" 4) "xl" # Add a value of "xl" without adding it, but no error is reported, set is the repeat 127.0.0.1: 6379> sadd set_ay_key "xl" (integer) 0 # Not much explanation 127.0.0.1: 6379> sadd set_ay_key "xl" (integer) 0 # Not much explanation 127.0.0.1: 6379> sadd set_ay_key "xl" (integer) 0
Example 3: add, delete, modify, and query a List set
# Add the list set 127.0.0.1: 6379> lpush list_ay_key "ay" "al" "xy" "xl" (integer) 4 # query the set of list_ay_key 127.0.0.1: 6379> lrange list_ay_key 0-11) "xl" 2) "xy" 3) "al" 4) "ay" # Add the element 127.0.0.1 to the end of the list: 6379> rpush list_ay_key "together" (integer) 5 # Add an element 127.0.0.1: 6379> lpush list_ay_key "first" (integer) 6 # query the list collection 127.0.0.1: 6379> lrange list_ay_key 0-11) "first" 2) "xl" 3) "xy" 4) "al" 5) "ay" 6) "together" # update the value 127.0.0.1: 6379> lset list_ay_key 0 "update_first" OK127.0.0.1: 6379> lrange list_ay_key 0-11) "update_first" 2) "xl" 3) "xy" 4) "al" 5) "ay" 6) "together" # Delete the value 127.0.0.1: 6379> lrem list_ay_key 1 "update_first" (integer) on index 1) 1127.0.0.1: 6379> lrange list_ay_key 0-11) "xl" 2) "xy" 3) "al" 4) "ay" 5) "together"
Example 4: add, delete, modify, and query of Hash sets (similar to Java)
127.0.0.1: 6379> flushdbOK # generate a hash set and add the key as uuid_one value as "12345" 127.0.0.1: 6379> hset hash_ay_key "uuid_one" 12345 "(integer) 1127.0.0.1: 6379> hlen hash_ay_key (integer) 1 # Return All key127.0.0.1: 6379> hkeys hash_ay_key1) "uuid_one" # Return All value127.0.0.1: 6379> hvals hash_ay_key1) "12345" # Add the value 127.0.0.1: 6379> hset hash_ay_key "uuuid_two" "22222" (integer) 1 # Add the value 127.0.0.1 to the set: 6379> hset hash_ay_key "random" "33333" (integer) 1 # obtain the uuid_one value 127.0.0.1: 6379> hget hash_ay_key uuid_one "12345" # Delete the uuid_three value 127.0.0.1: 6379> hdel hash_ay_key partition (integer) 1127.0.0.1: 6379> hkeys hash_ay_key1) "uuid_one" 2) "partition" # obtain all, including key and value127.0.0.1: 6379> hgetall hash_ay_key1) "uuid_one" 2) "12345" 3) "uuid_two" 4) "22222" # update the value of uuid_one 127.0.0.1: 6379> hset hash_ay_key uuid_one "11111" (integer) 0127.0.0.1: 6379> hset hash_ay_key "uuid_one" "11111" (integer) 0127.0.0.1: 6379> hgetall hash_ay_key1) "uuid_one" 2) "11111" 3) "uuid_two" 4) "22222"
Example 4: add, delete, modify, and query of SortedSet
SortedSet is an ordered set.
# Sorted set add value ay sorting value is 1127.0.0.1: 6379> zadd zset_ay_key 1 "ay" (integer) 1127.0.0.1: 6379> zadd zset_ay_key 2 "al" (integer) 1127.0.0.1: 6379> zadd zset_ay_key 3 "xy" (integer) 1127.0.0.1: 6379> zadd zset_ay_key 4 "xl" (integer) 1 # query all values 127.0.0.1: 6379> zrange zset_ay_key 0-11) "ay" 2) "al" 3) "xy" 4) "xl" # delete all values 127.0.0.1: 6379> zrem zet_ay_key "xl" (integer) 0127.0.0.1: 6379> zrange zset_ay_key 0-11) "ay" 2) "al" 3) "xy" 4) "xl"
Don't write it. It's so tired. It's all the same. Read the following article .....
Refer to master articles
Http://www.runoob.com/redis/redis-sorted-sets.html
Reading Comprehension
From Changjiang 7
-Xingye's family training for his son (three times in the film)-although we are poor, we can't lie or beat people. We can't take anything that is not ours; if you want to study hard and grow up, you must be a useful person to society.
Others
If there is a little bit of happiness for you, let the Happiness continue to pass on. You are welcome to repost, like, top, and leave valuable comments. Thank you for your support!