Redis API Usage Notes

Source: Internet
Author: User
Tags echo message

List Related:

Lpop key: Delete and get a list header element

Rpop key: Deletes and obtains an element of the list tail

Blpop key [key ...] timeout: delete and get the list header an element, if not on the block

Brpop key [key ...] timeout: delete and get an element of the list tail, if no block

Lpush key value: Expands an element in the list header

Rpush key value: extends an element at the tail of the list

Lpushx Key value: If list exists, expand an element in the list header

Rpushx Key value: If list exists, extend an element at the end of the list

LINDEX Key index: Gets an element of list by index

Llen key: Gets the length of the list

Lrange key start stop: Gets the list of elements within the specified range

Lrem Key Count value: Remove elements from list

LSET Key Index Value: Sets the values of the elements of the list index to index

LTRIM key start stop: Crop list, preserving a range of elements

Rpoplpush Source Destination: Deletes an element at the end of the current list and extends it to the tail of another list

Brpoplpush source destination timeout: pops up a list element and inserts it into another list, then returns if the previous list is empty block

SORT key [by pattern] [LIMIT offset count] [get pattern [get pattern ...]] [asc| DESC] [ALPHA] [STORE destination]: Sort List,set, SORTED SET

Set Correlation:

Sadd Key member: Adding a member to a set

Srem Key member: Remove a member from set

Sdiff key [Key ...]: Set differential set

SINTER key [Key ...]: Set intersection

Sunion key [Key ...]: Set Seek and set

Sdiffstore destination key [key ...]: Set differential set and save result set to another collection

Sinterstore destination key [key ...]: Sets the intersection and saves the result set to another collection

Sunionstore destination key [key ...]: Sets the set and saves the result set to another collection

SCard key: Gets the total number of Set members

Sismember Key member: Determines whether a given value is a set member

SPOP key: Delete and return set any member

Srandmember key: Returns a set of any member

Smembers key: Get all members of set

Smove Source Destination Member: Move one member of a set to another set

Zset Related:

Zadd Key Score member: Add a member to Sset, or update an existing member's score

Zcard key: Total number of members getting Sset

Zcount Key min Max: Calculates the total number of members score within a given range in Sset

Zincrby key: Self-increment for members in Sset score

Zinterstore destination Numkeys key [key ...] [WEIGHTS weight [weight ...] [AGGREGATE sum| min| MAX]: asks for Sset intersection and saves the result set to a new key

Zrange key start Stop [Withscores]: Returns members within a certain index range in Sset

Zrangebyscore key min Max [withscores] [LIMIT offset count]: Returns members within a certain score range in Sset

Zrem Key member: Remove a member from Sset

Zremrangebyrank key start stop: Remove Sset members within a certain index range

Zremrangebyscore Key min Max: Delete Sset members within a certain score range

Zrevrange key start Stop [Withscores]: Returns members within a certain index range in Sset, in order of score from high to low

Zrevrangebyscore key Max min [withscores] [LIMIT offset count]: Returns members within a certain score range of Sset, in order score from high to low

Zscore Key member: Get score associated with a given member in Sset

Zunionstore destination Numkeys key [key ...] [WEIGHTS weight [weight ...] [AGGREGATE sum| min| MAX]: Sset set and save the result set to a new key

Hash Related:

Hdel key field: Delete a Hashfield

Hexists key field: Determine if a hashfield exists

Hget key field: Get the value of a Hashfield

Hgetall key: Get a hash of all fields and values

Hincrby key field increment: Increase the integer value of increment to the integer value of Hashfield

Hkeys key: Get Hash of all field

Hlen key: Get the total number of field in hash

Hmget key field [Field ...]: Get hash specify all values for field

Hmset key field value [Field value ...]: Set some filed and value for hash

Hset key field value: Set a hash of a field for a value

Hsetnx key field value: When a field of hash does not exist, set it to a value

Hvals key: Get all values of hash

Key Related:

DEL key [key ...]: Delete a key

Get key: Get the value of a key

Setex Key seconds Value: Set Key's value and exp time

Setnx Key value: Sets the value of key, provided it does not exist before key

Set key value: Setting Key,value

APPEND key value: Extend a value to a key

Debug OBJECT key: Get debug information for a key

DECR key: Give a KEY-1

Decrby key integer: Give a Key-integer

EXISTS key: Determine if a key exists

EXPIRE Key seconds: Set TTL for a key (second)

Expireat key timestamp: Set TTL for a key (Unix timestamp)

TTL key: Get the TTL of key

PERSIST key: Remove expiration flag for a key

KEYS pattern: Find all the pattern-compliant keys

Move key DB: Moves one key to another database

RENAME key Newkey: Rename a key

Renamenx key Newkey: Rename a key if the new keyname does not exist

Randomkey: Returns a any key from Keyspace

Value Related:

GETRANGE key start end: Gets the substring of the specified range in the string corresponding to the key

Getset Key value: Sets the value corresponding to key and returns the old value

INCR key: The integer value corresponding to key is increased by 1

Incrby key increment: The integer value corresponding to the key is self-increment increment

MGET key [key ...]: Get the value of all specified keys

MSET key value [key value ...]: Sets the values specified for the specified keys

Msetnx key value [key value ...]: When the specified key is present, the specified values are set for the specified keys

STRLEN key: Gets the value length of key

Server-Related:

Info: Get status information and statistics for the server

Monitor: Real-time monitoring of all requests received by the server

Ping:ping Server

QUIT: Close Link

PUBLISH Channel message: Post a message to a channel

AUTH Password: Authentication server

Lastsave: Time stamp for the last successful Savetodisk

Object subcommand [arguments [arguments ...]: detects the interior of a Redis object

Psubscribe pattern [pattern ...]: listens to all pattern-compliant messages posted to the channel

Punsubscribe [pattern [pattern ...]]: Stop listening for all pattern messages posted to the channel

CONFIG resetstat: Reset the status information returned by the info command

SUBSCRIBE Channel [Channel ...]: listens for messages for the specified channel

unsubscribe [Channel [channel ...]: Stop listening for messages from the specified channel

Unwatch:forget about all watched keys stop monitoring all monitored keys

Watch key [key ...]: monitor all given keys to determine the execution of multi and exec blocks

Database Related:

Save synchronously: Saving DataSet to Hard disk

SELECT Index: Toggle the current database

BGSAVE: Asynchronously saves the DataSet to the hard disk

Dbsize: Returns the total number of keys for a database

Flushall: Delete all keys on database

FLUSHDB: Delete all keys on the current database

SHUTDOWN synchronously: After saving the dataset to the hard disk, shut down the server

Configuration Related:

Config get parameter: Get a configuration parameter value

CONFIG Set parameter value: Sets a configuration parameter to the given value

Other:

Getbit Key offset: Returns the value of the key corresponding to the bit values in offset

MULTI: Identifies the beginning of a business block

SETRANGE Key offset value: overwrites the value string corresponding to the write key from the specified offset

Bgrewriteaof: Async rewrite append-only file

DEBUG Segfault: Make the server crash

DISCARD: Ignores all commands that start with multi

ECHO Message:echo Message

EXEC: Executes all commands that start with multi

Slaveof host Port: Make this server A slave of another Redis host, or make this server a master server

SYNC: Internal backup command

Linsert Key before| After Refvalue value: Insert value before or after the refvalue of the list key

Zrank Key member: Returns the rank (subscript) of the specified element in the collection, in which the elements are sorted by score from small to large

Zrevrank Key member: Ditto, but the elements in the collection are sorted by score from large to small

Type key: Returns the value type of the given key. Return none indicates that no key,string character type exists, list linked list type set unordered collection type

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.