redis命令学习
发布日期:2021-05-06 23:39:30 浏览次数:8 分类:技术文章

本文共 7467 字,大约阅读时间需要 24 分钟。

redis web 在线测试版

CommandReference

Every command name links to a specific wiki page describing the behavior of the command.Every command name links to a specific wiki page describing the behavior of the command.
CommandReference: Contents
    
    
    
    
    
    
    
    
    
    
    
    
    

Command Parameters Description
- close the connection
password simple password authentication if enabled

Command Parameters Description
key test if a key exists
key delete a key
key return the type of the value stored at key
pattern return all the keys matching a given pattern
- return a random key from the key space
oldname newname rename the old key in the new one, destroying the newname key if it already exists
oldname newname rename the oldname key tonewname, if thenewname key does not already exist
- return the number of keys in the current db
- set a time to live in seconds on a key
- remove the expire from a key
- get the time to live in seconds of a key
index Select the DB with the specified index
key dbindex Move the key from the currently selected DB to thedbindex DB
- Remove all the keys from the currently selected DB
- Remove all the keys from all the databases

Command Parameters Description
key value Set a key to a string value
key Return the string value of the key
key value Set a key to a string returning the old value of the key
key value Set a key to a string value if the key does not exist
key time value Set+Expire combo command
key offset value Set bit at offset to value
key offset Return bit value at offset
key1 value1 key2 value2 ...keyN valueN Set multiple keys to multiple values in a single atomic operation
key1 value1 key2 value2 ...keyN valueN Set multiple keys to multiple values in a single atomic operation if none of the keys already exist
key1 key2 ... keyN Multi-get, return the strings values of the keys
key Increment the integer value of key
key integer Increment the integer value of key by integer
key Decrement the integer value of key
key integer Decrement the integer value of key by integer
key value Append the specified string to the string stored at key
key start end Return a substring of a larger string

Command Parameters Description
key value Append an element to the tail of the List value at key
key value Append an element to the head of the List value at key
key Return the length of the List value at key
key start end Return a range of elements from the List at key
key start end Trim the list at key to the specified range of elements
key index Return the element at index position from the List at key
key index value Set a new value as the element at index position of the List at key
key count value Remove the first-N, last-N, or all the elements matching value from the List at key
key Return and remove (atomically) the first element of the List at key
key Return and remove (atomically) the last element of the List at key
key1 key2 ... keyN timeout Blocking LPOP
key1 key2 ... keyN timeout Blocking RPOP
srckey dstkey Return and remove (atomically) the last element of the source List stored atsrckey and push the same element to the destination List stored atdstkey
srckey dstkey Like RPOPLPUSH but blocking of source key is empty

Command Parameters Description
key member Add the specified member to the Set value at key
key member Remove the specified member from the Set value at key
key Remove and return (pop) a random element from the Set value at key
srckey dstkey member Move the specified member from one Set to another atomically
key Return the number of elements (the cardinality) of the Set at key
key member Test if the specified value is a member of the Set at key
key1 key2 ... keyN Return the intersection between the Sets stored at key1, key2, ..., keyN
dstkey key1 key2 ... keyN Compute the intersection between the Sets stored at key1, key2, ..., keyN, and store the resulting Set at dstkey
key1 key2 ... keyN Return the union between the Sets stored at key1, key2, ..., keyN
dstkey key1 key2 ... keyN Compute the union between the Sets stored at key1, key2, ..., keyN, and store the resulting Set at dstkey
key1 key2 ... keyN Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN
dstkey key1 key2 ... keyN Compute the difference between the Set key1 and all the Sets key2, ..., keyN, and store the resulting Set at dstkey
key Return all the members of the Set value at key
key Return a random member of the Set value at key

Command Parameters Description
key score member Add the specified member to the Sorted Set value at key or update the score if it already exist
key member Remove the specified member from the Sorted Set value at key
key increment member If the member already exists increment its score byincrement, otherwise add the member settingincrement as score
key member Return the rank (or index) or member in the sorted set at key, with scores being ordered from low to high
key member Return the rank (or index) or member in the sorted set at key, with scores being ordered from high to low
key start end Return a range of elements from the sorted set at key
key start end Return a range of elements from the sorted set at key, exactly like ZRANGE, but the sorted set is ordered in traversed in reverse order, from the greatest to the smallest score
key min max Return all the elements with score >= min and score <= max (a range query) from the sorted set
key min max Return the number of elements with score >= min and score <= max in the sorted set
key Return the cardinality (number of elements) of the sorted set at key
key element Return the score associated with the specified element of the sorted set at key
key min max Remove all the elements with rank >= min and rank <= max from the sorted set
key min max Remove all the elements with score >= min and score <= max from the sorted set
dstkey N key1 ... keyN WEIGHTSw1 ...wN AGGREGATE SUM|MIN|MAX Perform a union or intersection over a number of sorted sets with optional weight and aggregate

Command Parameters Description
key field value Set the hash field to the specified value. Creates the hash if needed.
key field Retrieve the value of the specified hash field.
key field1 ... fieldN Get the hash values associated to the specified fields.
key field1 value1 ... fieldN valueN Set the hash fields to their respective values.
key field integer Increment the integer value of the hash atkey onfield withinteger.
key field Test for existence of a specified field in a hash
key field Remove the specified field from a hash
key Return the number of items in a hash.
key Return all the fields in a hash.
key Return all the values in a hash.
key Return all the fields and associated values in a hash.

Command Parameters Description
key BY pattern LIMITstart end GETpattern ASC|DESC ALPHA Sort a Set or a List accordingly to the specified parameters

Command Parameters Description
- Redis atomic transactions

Command Parameters Description
- Redis Public/Subscribe messaging paradigm implementation

Command Parameters Description
- Synchronously save the DB on disk
- Asynchronously save the DB on disk
- Return the UNIX time stamp of the last successfully saving of the dataset on disk
- Synchronously save the DB on disk, then shutdown the server
- Rewrite the append only file in background when it gets too big

Command Parameters Description
- Provide information and statistics about the server
- Dump all the received requests in real time
- Change the replication settings
- Configure a Redis server at runtime
上一篇:剑指offer Leetcode 52. 两个链表的第一个公共节点
下一篇:剑指offer Leetcode 35.复杂链表的复制

发表评论

最新留言

很好
[***.229.124.182]2025年04月04日 03时51分25秒