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

Collation of Redis common commands

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

Share

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

Redis basic command command description ping is used to detect whether the redis service is started info view redis information select choose a different keyspace Or databasekeys * View all keyflushdb under current keyspace empty data under current keyspace flushall empty data under all keyspace View a key value pair under current keyspace persist the data stored in redis to disk quit exit client command line Redis key command description del key this command is used to delete keydump key serialize a given key when key exists and return the serialized value exists key to check whether the given key exists. Existence returns 1 There is no return 0expire key seconds to set the expiration time for a given key expireat key timestampEXPIREAT is similar to EXPIRE in that it is used to set the expiration time for key. The difference is that the time parameter accepted by the EXPIREAT command is the UNIX timestamp (unix timestamp) pexpire key milliseconds sets the expiration time of the key in milliseconds pexpireat key milliseconds-timestamp sets the timestamp of the key expiration time (unix timestamp) in milliseconds keys pattern finds all keymove key db that matches a given schema (pattern) moves the key of the current database to a given database db or keyspace, that is, the expiration time of persist key removing key in milliseconds Key persists the remaining expiration time of the key returned by pttl key in milliseconds.-1 indicates that there is no expiration time,-2 indicates that there is no ttl key in the key, returns the remaining survival time (TTL, time to live) of a given key,-1 indicates that there is no expiration time,-2 indicates that there is no randomkey to randomly return the name renamenx key newkey of a keyrename key newkey modified key from the current database only if the newkey does not exist. Rename key to newkeytype key and return the type of value stored by key Redis data structure: String string command describes set key value setting the value of specified key get key gets the value of specified key getrange key start end returns the subcharacter getset key value of the string value in key sets the value of a given key to value and returns the old value of key (old value) getbit key offset to the string value stored by key to get the bit (bit) mget key1 [key2..] on the specified offset Gets all (one or more) values of a given key setbit key offset value stored string values for key, sets or clears the bit (bit) on the specified offset setex key seconds value associates the value value to key, and sets the expiration time of key to seconds (in seconds) setnx key value only sets the value of key when key does not exist setrange key offset value overwrites the stored string value of a given key with the value parameter Starting with the offset offset, strlen key returns the length of the string value stored by key mset key value [key value.] Set one or more key-value pairs to msetnx key value [key value.] Set one or more key-value pairs at the same time if and only if psetex key milliseconds value does not exist for all given key this command is similar to the SETEX command, but it sets the lifetime of the key in milliseconds, not like the SETEX command Incr key increments the numeric value stored in key in seconds incrby key increment adds the value stored by key to the given increment value (increment) incrbyfloat key increment adds the value stored by key to the given floating point increment value (increment) decr key minus the value stored in key minus the value stored by decrby key decrementkey minus the given decrement append key value if key already exists and is a string The APPEND command appends the specified value to the end of the Redis data structure of the original value (value) of the key: the hash hash command describes that hset key field value sets the value of the field field in the hash table key to valuehdel key field1 [field2] Delete one or more hash table fields hexists key field view hash table key Whether the specified field exists hget key field gets the value of the specified field stored in the hash table hgetall gets all the fields and values of the specified key in the hash table hincrby key field increment is the integer value of the specified field in the hash table key plus the increment incrementhincrbyfloat key field increment is the floating-point value of the specified field in the hash table key plus the increment incrementhkeys key gets the field hlen key in all the hash table to get the number of fields in the hash table hmget key Field1 [field2] gets the values of all given fields hmset key field1 value1 [field2 value2] sets multiple field-value (field-value) pairs to the hash table key at the same time hsetnx key field value only if the field field does not exist Set the value of the hash table field hvals key to get all the values in the hash table hscan key cursor [MATCH pattern] [COUNT count] key-value pairs in the iterative hash table Redis data structure: the list list command describes blpop key1 [key2] timeout to remove and get the first element of the list, if the list has no elements to block the list until waiting for a timeout or to find a popup element brpop key1 [key2] timeout removes and gets the last element of the list If no element in the list blocks the list until waiting for a timeout or finding a popup element, brpoplpush source destination timeout pops a value from the list, inserts the pop-up element into another list and returns it If no element in the list blocks the list until waiting for a timeout or finding a popup element lindex key index gets the element linsert key before in the list through the index | after pivot value inserts the element before or after the list element llen key gets the list length lpop key removes and gets the first element of the list lpush key value1 [value2] inserts one or more values into the list header lpushx key value inserts a value into the existing The list header lrange key start stop gets the elements within the specified range of the list lrem key count value remove list element lset key index value trims a list by setting the value of the list element ltrim key start stop (trim) That is to say, let the list keep only the elements within the specified range, and all elements that are not within the specified range will be deleted. Rpop key removes and gets the last element of the list rpoplpush source destination removes the last element of the list. And add this element to another list and return rpush key value1 [value2] add one or more values to the list rpushx key value add values Redis data structure: collection set command description sadd key member1 [member2] add one or more members to the collection scard key gets the number of members of the collection sdiff key1 [key2] returns the difference of all given sets sdiffstore destination key1 [key2] returns the differences of all given sets Set and store in destination sinter key1 [key2] returns the intersection of all given sets sinterstore destination key1 [key2] returns the intersection of all given sets and stores them in destination sismember key member determines whether the member element is a member of the set key smembers key returns all members of the set smove source destination member moves the member element from the source collection to the destination collection spop key removes and returns a random element in the set srandmember key [count] random return set Members in a combination srem key member1 [member2] remove one or more members of a collection sunion key1 [key2] returns the union of all given collections sunionstore destination key1 [key2] the union of all given collections is stored in the sscan key cursor [MATCH pattern] [COUNT count] iterative collection in the destination collection element Redis data structure: ordered sets sorted set commands describe zadd key score1 member1 [score2 member2] to add one or more members to an ordered collection Or update the score of the existing member zcard key to get the number of members of the ordered set zcount key min max calculate the number of members of the specified interval score in the ordered set zincrby key increment member the score of the specified member is added to the score of the specified member by increment incrementzincrbystore destination numkeys key [key.] Calculates the intersection of a given ordered set or sets and stores the result set in a new ordered set key. Zlexcount key min max calculates the number of members in the specified dictionary interval zrange key start stop [WITHSCORES] returns the ordered set through the index interval to synthesize the members in the specified interval zrangebylex key min max [LIMIT offset count] the member zrangebyscore key min max [WITHSCORES] [LIMIT] returns the ordered set through the dictionary interval Zrank key member returns the index zrem key member [member...] of the specified member in the ordered set. Remove one or more members of an ordered set zremrangebylex key min max removes all members of a given dictionary interval in an ordered set zremrangebyrank key start stop removes all members of a given ranking interval in an ordered set zremrangebyscore key min max removes all members of a given fractional interval in an ordered set zrevrange key start stop [WITHSCORES] returns members in a specified interval in the ordered set by indexing Score from high to bottom zrevrangebyscore key max min [WITHSCORES] returns the members within the specified score range in the ordered set, zrevrank key member returns the ranking of the specified members in the ordered set, zscore key member returns the ordered set by decreasing score value (from large to small), and the score value of the member zunionstore destination numkeys key [key.] Calculates the union of one or more given ordered sets and stores the elements (including element members and element scores) in the zscan key cursor [MATCH pattern] [COUNT count] iterative ordered set in the new 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

Wechat

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

12
Report