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 operate using Redis

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how to use Redis. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

one。 Start and shut down

Load configuration file startup

Redis-server Redis.conf

Shutting down the Redis,Redis server will break the link with the client, generate persistent files, and close smoothly. The way of kill pid number is the same.

Do not use kill-9 to force killing. This will not make it persistent, and will cause resources such as buffers not to be gracefully closed. In extreme cases, it will cause AOF and replication to lose data.

Redis-cli shutdown

Link Redis server-h address-p port-c means to link a cluster

Redis-cli-h 127.0.0.1-p 7000

Link to the Redis server, non-interactive. Just add the command at the end to get name.

Redis-cli get name

Display the key value of the large one

Redis-cli-bigkeys

View statistics

Redis-cli-stat

two。 Basic operation

The query shows all key. Only valid data, not out-of-date data. If the amount of data is very large, do not use this command, it will cause memory jam.

Keys *

Query the number of all key, not destroyed. (expired ones are also counted)

Dbsize

Check what are the linked clients

Client list

Kill the client link

Client kill 127.0.0.1:52343

View

1. Current number of client connections

two。 The maximum number of queue objects in all current output buffers

3. Maximum capacity currently occupied in all input buffers

4. The number of clients executing blocking commands (for example, blpop, brpop, brpoplpush).

Info clients

View various details

Info

Query the directory of stored files

CONFIG GET dir

Check to see if the key exists. 1 exists, 0 does not exist

Exists key

Delete keys, you can delete multiple keys at the same time

Del key

Sets the expiration time for the key value. Unit second, 1 successful, 0 unsuccessful

Expire key 10

Check the remaining expiration time of key. Return-2 key does not exist,-1 is not set, greater than 0 is the remaining time

Ttl key

View the key data structure type. Return none Yes key does not exist

Type key

Check the internal coding format

Object encoding key

Rename key, and if newkey already exists, the value will be overwritten

Rename key newkey

Rename key. If newkey already exists, the operation will fail, return 0, and do nothing.

Renamenx key newkey

If there are 1000 key:value, a key will be randomly returned

Randomkey

Thank you for reading! This is the end of this article on "how to operate and use 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.

Share To

Servers

Wechat

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

12
Report