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

Latest summary of Redis-cli command

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

Share

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

Commands related to connection operations

Default direct connection remote connection-h 192.168.1.20-p 6379

Ping: tests whether the connection is alive and returns pong if it is normal

Echo: printing

Select: switch to the specified database. The database index number index is specified by a numeric value with 0 as the starting index value.

Quit: close connection (connection)

Auth: simple password authentication

Server related commands

Time: returns the current server time

Client list: returns all client information and statistics connected to the server see http://redisdoc.com/server/client_list.html

Client kill ip:port: shut down the client with the address ip:port

Save: save data synchronization to disk

Bgsave: save data asynchronously to disk

Lastsave: returns the Unix timestamp of the last time data was successfully saved to disk

Shundown: save data synchronization to disk, and then shut down the service

Info: provides server information and statistics

Config resetstat: reset some statistics in the info command

Config get: get profile information

Config set: dynamically adjust the configuration of the Redis server (configuration) without restarting. The configuration parameters that can be modified can be listed using the command CONFIG GET *

Rewrite the redis.conf file specified by the config rewrite:Redis server

Monitor: real-time dump of received requests

Slaveof: change replication policy settings

Publish and subscribe related commands

Psubscribe: subscribe to one or more channels that match a given pattern, such as psubscribe news.* tweet.*

Publish: sends the message message to the specified channel channel, such as publish msg "good morning"

Pubsub channels: lists current active channels such as PUBSUB CHANNELS news.i*

Pubsub numsub: returns the number of subscribers for a given channel, such as PUBSUB NUMSUB news.it news.internet news.sport news.music

Pubsub numpat: returns the total number of all patterns subscribed by the client

Punsubscribe: instructs the client to unsubscribe from all given modes.

Subscribe: subscribe to information for a given channel or channels. For example, subscribe msg chat_room

Unsubscribe: instructs the client to unsubscribe from the given channel.

Commands for KEY operations

Exists (key): confirm whether a key exists

Del (key): delete a key

Type (key): type of return value

Keys (pattern): returns all key that satisfy a given pattern

Randomkey: one of the randomly returned key spaces

Keyrename (oldname, newname): rename key

Dbsize: returns the number of key in the current database

Expire: set the active time of a key (s)

Ttl: get the active time of a key

Move (key, dbindex): move the key in the current database to the dbindex database

Flushdb: deletes all key in the currently selected database

Flushall: delete all key in all databases

Commands for String operations

Set (key, value): assigns the value value to the string named key in the database

Get (key): returns the value of the string named key in the database

Getset (key, value): assign the last value to the string named key

Mget (key1, key2, … , key N): returns the value of multiple string in the library

Setnx (key, value): add string with the name key and the value value

Setex (key, time, value): add string to the library and set the expiration time time

Mset (key N, value N): set the values of multiple string in batch

Msetnx (key N, value N): if all string named key I do not exist

Incr (key): string add 1 operation named key

Incrby (key, integer): string named key adds integer

Decr (key): string minus 1 operation named key

Decrby (key, integer): string named key reduces integer

Append (key, value): the value of the string named key is appended to value

Substr (key, start, end): returns the substring of the value of string with the name key

Commands for List operations

Rpush (key, value): add an element with the value value to the end of the list named key

Lpush (key, value): add an element with a value of value to the list header named key

Llen (key): returns the length of the list named key

Lrange (key, start, end): returns the element between start and end in the list named key

Ltrim (key, start, end): intercept list named key

Lindex (key, index): returns the element of the index location in the list named key

Lset (key, index, value): assign a value to the element of index position in the list named key

Lrem (key, count, value): delete the element whose value is value in the list of count key

Lpop (key): returns and deletes the first element in the list named key

Rpop (key): returns and deletes the tail element in the list named key

Blpop (key1, key2, … Key N, timeout): the block version of the lpop command.

Brpop (key1, key2, … Key N, timeout): the block version of rpop.

Rpoplpush (srckey, dstkey): returns and deletes the trailing element of the list named srckey and adds it to the header of the list named dstkey

Commands for Set operations

Sadd (key, member): add the element member to the set named key

Srem (key, member): deletes the element member in the set named key

Spop (key): randomly returns and deletes an element in the set named key

Smove (srckey, dstkey, member): move to a collection element

Scard (key): returns the cardinality of the set named key

Sismember (key, member): whether member is an element of set named key

Sinter (key1, key2, … Key N): find the intersection

Sinterstore (dstkey, (keys)): find the intersection and save the intersection to the collection of dstkey

Sunion (key1, (keys)): Union set

Sunionstore (dstkey, (keys)): join and save the union to the collection of dstkey

Sdiff (key1, (keys)): subtraction set

Sdiffstore (dstkey, (keys)): take the difference set and save the difference set to the collection of dstkey

Smembers (key): returns all elements of a set named key

Srandmember (key): randomly returns an element of set with the name key

Commands for Hash operations

Hset (key, field, value): add the element field to the hash named key

Hget (key, field): returns the value corresponding to field in the hash named key

Hmget (key, (fields)): returns the value corresponding to field I in the hash named key

Hmset (key, (fields)): add the element field to the hash named key

Hincrby (key, field, integer): add integer to the value of field in the hash named key

Hexists (key, field): whether there is a domain with the key field in the hash named key

Hdel (key, field): delete the domain with the key field in the hash named key

Hlen (key): returns the number of elements in a hash named key

Hkeys (key): returns all keys in the hash with the name key

Hvals (key): returns the value of all keys in the hash named key

Hgetall (key): returns all keys (field) and their corresponding value in the hash named key

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