In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you what are the basic knowledge points of redis. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Redis is a high-performance key-value database. The emergence of redis makes up for the deficiency of keyvalue storage such as memcached to a great extent, and can play a good complementary role to relational database in partial situations.
First, install Redis
Redis configuration file: / etc/redis.conf
Redis main program: / usr/bin/redis-server
Client tool: / usr/bin/redis-cli
Default listening port: 6379
Data directory: / var/lib/redis
Service script: / usr/lib/systemd/system/redis.service
Yum install redis # CentOS7-based epel source II. Connect Redis
The client command tool for Redis is redis-cli, which connects to the local Redis service by default.
If a remote connection is required, use redis-cli-h HOST-p PORT-a PASSWD
[root@cache1 ~] # redis-cli127.0.0.1:6379 > ping # use the ping command to test the connectivity with the service PONG # the server reply pong indicates that there is no problem with the network connection. 3. Redis data type
String (string)
String is the most basic type of redis, which you can understand as exactly the same type as Memcached, with a key corresponding to a value.
The string type is binary safe. It means that the string of redis can contain any data. Such as jpg images or serialized objects.
String type is the most basic data type of Redis, and a key can store 512MB as much as possible.
Hash (hash)
Redis hash is a collection of key-value pairs (key= > value).
Redis hash is a mapping table for field and value of type string, and hash is particularly suitable for storing objects.
List (list)
The Redis list is a simple list of strings sorted in the order in which they are inserted. You can add an element to the head (left) or tail (right) of the list.
Set (collection)
The Set of Redis is an unordered collection of type string.
The collection is implemented through a hash table, so the complexity of adding, deleting, and finding is all O (1).
Zset (sorted set: ordered set)
Redis zset, like set, is a collection of elements of type string, and duplicate members are not allowed.
The difference is that each element is associated with a score of type double. Redis sorts the members of the collection from small to large by scores.
The members of the zset are unique, but the score can be repeated.
Get help help @ + double-click tab # double-click tab will appear the help of each subcommand help @ string # string-related configuration help @ list # list related configuration; the list is similar to the array help @ sethelp @ hash. V. commands related to List
Several other data types are relatively simple, and you can get how to use the command with help. The easiest way is Baidu. Since it is difficult to understand some operations of List-related commands only by looking at help, I will talk about some of the most commonly used commands separately.
Example:
127.0.0.1 integer 6379 > LPUSH stu aubin # LPUSH, add elements to the left side of the list, there is no automatic creation (integer) 1127.0.1 integer > RPUSH stu 22 # RPUSH, add elements to the right side of the list, if the list does not exist, automatically create (integer) 2127.0.0.1 integer 6379 > RPUSHX stu nan # RPUSHX If the list exists, add the element (integer) 3127.0.0.1 LPUSHX 6379 > LPUSHX stu linux # LPUSHX on the right, and add the element (integer) 4127.0.0.1 LPUSHX 6379 > LRANGE stu 0 10 # LRANGE on the left if the list exists Display 0-10 values of the list named stu 1) "aubin" 2) "22" 3) "nan" 4) "linux" LPOP stu # left, delete the first element in the list named stu, RPOP stu # right Delete the last element in the list named stu LREM stu 3 aubin # delete 3 elements with value aubin LREM stu-3 aubin # delete 3 elements with value aubin LREM stu 0 aubin # delete all elements with value aubin thank you for reading! This is the end of this article on "what are the basic knowledge points of redis?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.