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

Redis common operation commands

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Connection related:

Redis-cli-h-p shutdown # shutdown

Redis-cli [- c]-h-p # connection if you want to add this parameter to the cluster. For example, you need to enter AUTH for subsequent operations after enabling authentication connection.

Post-connection help information:

Help # display version, help usage, help @ command group, help

Determine the type of key: type key

@ server

CLIENT SETNAME sets the client name. Default is empty.

CLIENT GETNAME gets the client name

CLIENT KILL IP:PORT shuts down a port

Info views all the information

Info memory only views information related to memory

FLUSHDB empties the current library

FLUSHALL clears all libraries

CONFIG [SET | GET | RESETSTAT | REWRITE]

The parameters of the configuration file redis.conf can be configured again through config set and only take effect in memory. If you want to permanently take effect, save the settings in the configuration file with config REWRITE.

@ string string related

Set [EX seconds expiration time seconds] [created only if NX does not exist | XX is set only if it exists] # set system Cent

Setnx is equivalent to set NX.

Setxx is equivalent to set XX.

Get example: get system "Cent"

APPEND is appended after key, for example: append system OS; get system "CentOS"

Strlen length example: strlen system (integer) 6

Incr increases the integer value by 1 example: set NUM 2; incr NUM; get NUM-"3"

Decr reduces the integer value by 1.

Exists check to see if there is a return of 1, and if there is no, return 0.

@ list list related

Rpush key value inserts an element from the right, for example: rpush NO1 one two three

LINDEX key index gets the element in the group example: lindex NO1 0 gets the element with index 0, one

Lpush key value inserts an element from the left, for example: rpush NO2 one two three; lindex NO2 0 gets the element with index 0, three

Llen key view the number of elements in the list

Lpop pops up an element on the left

Rpop pops up an element on the right

Lset modifies element example lset NO1 0 mon changes the 0th element to mon

@ set Collection

Sadd key member adds one or more elements to the collection SADD w1 mon tue wed thu fre sat sun # add {xx}: identification before the key when set in the cluster, otherwise some functions cannot be used if the data is not stored in a slot

Scard key gets the number of elements in a collection

SMEMBERS key gets all the elements in the collection

Before sinter finds the intersection sinter w1 w2 # cluster key, specify {xx}: ID

Sunion union set

Spop pops up an element at random

Whether sismember W1 mon # mon is an element of W1, correct return 1, error return 0

@ sorted_set ordered set

Zadd sets zadd weekday 1 mon 2 tue 3 wed

Number of zcard weekday elements

Zscore weekday 1 looks at the elements corresponding to the index

Zrank weekday tue to check the corresponding index number

Zrange weekday 0 2 views all elements corresponding to 0-2, and terminates it as-1 to represent the last bit.

Zrangebyscore gets the collection through score

@ hash mapping, associative array

Hset hset h2 a mon

Hget hget h2 a

Hkeys hkeys H2 view all the values in the key

Hdel hkeys H2 delete specific field

Del key deletes the entire key

Hgetall key gets all the fields and values that specify key in the hash table

HVALS key gets all the values in the hash table

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

Database

Wechat

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

12
Report