Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of Connection in Redis

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you what the role of Connection in Redis is, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The AUTH command is used to detect whether the password is consistent with the password in the configuration file. If so, the server will return OK and continue to accept the following commands, otherwise, Redis will refuse to execute the next commands.

127.0.1 6379 > config set requirepass "mypass"

OK

127.0.0.1 purl 6379 > AUTH my

(error) ERR invalid password

127.0.0.1 purl 6379 > ping

(error) NOAUTH Authentication required.

127.0.0.1 purl 6379 > AUTH mypass

OK

127.0.0.1 purl 6379 > ping

PONG

It should be noted that because Redis has very high read and write performance, it can handle many AUTH operations in a period of time, which increases the possibility that the password will be violently cracked, so we need to make the password as secure as possible when setting the password.

Available version of ECHO: 1.0.0

The ECHO command prints a string.

127.0.1 6379 > ECHO "Hello!"

Available version of "Hello!" PING: 1.0.0

The PING command is used to detect whether the server is running or to test delays. Normally, if there is no parameter, the server will return a PONG, and if there is a parameter, the server will copy the parameter and return it as a string.

127.0.0.1 purl 6379 > PING

PONG

127.0.1 6379 > PING "hi"

Available version of "hi" QUIT: 1.0.0

The QUIT command closes the current connection and closes the current connection as soon as all pending replies are written to the client.

Available version of SELECT: 1.0.0

The SELECT command is used to switch the database, and the parameter is the database index number. The default database index number for a new connection is 0, and all databases are persisted to the same RDB or AOF file. Different databases can have the same key.

127.0.0.1 SELECT 6379 > 1

OK

127.0.0.1 purl 6379 [1] >

After you switch the database, the database index number appears after the prompt. It is important to note that when using Redis Cluster, you cannot use the SELECT command.

Available version of SWAPDB: 4.0.0

SWAPDB is used to exchange two databases, and other clients connected to this database will immediately see the data of the other database.

# client 0

127.0.0.1 purl 6379 > set db db_0

OK

127.0.0.1 purl 6379 > get db

"db_0"

127.0.0.1 SWAPDB 6379 > 0 1

OK

127.0.0.1 purl 6379 > get db

(nil)

# client 1

127.0.0.1 SELECT 6379 > 1

OK

127.0.0.1 get db [1] >

The above content of "db_0" is what is the function of Connection in Redis. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report