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

How to set permanent validity with Redis

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to set up permanent effectiveness with Redis". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn how to use Redis to set up permanent effectiveness.

How to set permanent validity

PERSIST key

Persist key and value

Redis adopts noeviction recycling strategy by default, that is, it does not eliminate any key-value pairs. When the memory is full, it can only provide read operations, not write operations.

Redis set password

There are two ways to set a password.

1. The command line sets the password

Run cmd to change to the redis root directory and start the server first

> redis-server.exe

Open another cmd to change to the redis root directory and start the client

> redis-cli.exe-h 127.0.0.1-p 6379

The client uses the config get requirepass command to view the password

> config get requirepass1) "requirepass" 2) "/ / default is empty

The client uses the config set requirepass yourpassword command to set the password

> config set requirepass 123456 > OK

Once the password is set, the pass password must be verified first, otherwise all operations will not be available

Config get requirepass (error) NOAUTH Authentication required

Use auth password to verify passwords

> auth 123456 > OK > config get requirepass1) "requirepass" 2) "123456"

You can also log out and log back in

Redis-cli.exe-h 127.0.0.1-p 6379-a 123456

The password set by the command line expires after the service is restarted, so this method is generally not used.

two。 Profile set password

Locate the redis.windows.conf configuration file in the redis root directory, search requirepass, find the comment password line, and add the password as follows:

# requirepass foobaredrequirepass tenny / / Note that there can be no spaces before the line

After restarting the service, the client logs back in and discovers that

> config get requirepass1) "requirepass" 2) ""

Is the password still empty?

The method after the online query: create a shortcut to redis-server.exe, right-click the shortcut property, and add redis.windows.conf after the target, here is the key, although you modified the .conf file, but exe does not use this conf, so we need to manually specify exe to run in accordance with the modified conf, on OK.

So, here I restart the redis service again (specify the configuration file)

> redis-server.exe redis.windows.conf

The client logs in again, OK.

> redis-cli.exe-h 127.0.0.1-p 6379-a 123456 > config get requirepass1) "requirepass" 2) "123456" Thank you for reading. The above is the content of "how to set permanent validity with Redis". After the study of this article, I believe you have a deeper understanding of how to set permanent validity with Redis, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Development

Wechat

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

12
Report