Redis Common directives

Source: Internet
Author: User
Tags add numbers delete key min redis

Redis Instructions

1. General Instructions

1.1 Cases of matching key:keys pattern

1.2 Determine if key exists:

Exists key

1.3 Delete key:

Del Key1 [Key2,key3 ...]

1.4 View Build Type:

Type key

127.0.0.1:6379>type Test

String

2 string Instruction

2.1 Write String

Set key value

Eg:set name Zhang San

2.2 Read the built-in values:

Get key

2.3 Self-increment (value +1):

INCR key

2.4 Specify the number of self-increment:

Incrby Key Increment

Number of command builds added

2.5 Self-subtraction:

DECR key

2.6 Specify the number of auto-subtract:

Decrby Key Decrement

2.7 Increase the specified floating point number:

Incrbyfloat Key Floatvalue

2.8 Tail Best Value:

Append key value

2.9 Get string Length:

Strlen Key

2.10 Get multiple simply:

Mget key1 Key2 ...

2.11 Get bit:

Getbit Key Offset

2.12 Setting the bit:

Setbit Key Offset value

3 Hash type

3.1 Assignment:

Hset key field value

3.2 Value:

Hget key Field

3.3 Multi-field assignment:

Hmset key field1 values Field2 values ...

3.4 Get the multi-field value in key:

Hmget key Field1 Filed2 ...

3.5 Get all values in key

Hgetall Key

3.6 Determine if a field exists:

Hexists key Field

3.7 Assign a value when the field does not exist:

Hsetnx key field value

3.8 Fields Add Numbers:

Hincrby key field Increment

3.9 Delete a field:

Hdel key Field

3.10 Get all field names:

Hkeys Key

3.11 Get all field values:

Hvals Key

3.12 View number of fields:

Hlen Key

4 List types:

4.1 Append list value to left:

Lpush key Val1 Val2 [Val ....]

4.2 Append list value to the right:

Rpush key Val1 Val2 [Val ....]

4.3 A value pops up on the left:

Lpop Key

4.4 A value pops up on the right:

Rpop Key

4.5 List Length:

Llen Key

4.6 Get list range values:

Lrange Key Start stop

4.7 Gets the specified subscript value:

Lindex Key Index

4.8 setting Specifies the subscript value:

LSet Key index value

4.9 Keep the specified subscript content:

LTrim Key Start stop

Retains the value from start to stop in key, startstop are integers.

4.10 Insert a value before/after the specified element position:

Linsert Key Before|after Pivot value

Find the pivot value in the key set and put value before or after the pivot value;

4.11 Transfer an element from a list to a list of columns:

Lpoplpush Source Destination

5 collection type

5.1 Adding a Collection element:

Sadd key Member1 member2 [...]

5.2 Removing a collection element:

Srem key Member1 member2 [...]

5.3 Viewing collection elements:

Smembers Key

5.4 Determine whether an element exists in the collection:

Sismember Key Member

5.5 Take set difference set:

Sdiff key1 Key2 [...]

5.6 Take set Intersection:

Sinter key1 Key2 [...]

5.7 Taking the set of the collection:

Sunion key1 Key2 [...]

5.8 Gets the number of elements in the collection:

SCard Key

5.9 Set operation and storage:

Sdiffstore destination Key1 key2 [...]

Sdiffstore destination Key1 key2 [...]

Sdiffstore destination Key1 key2 [...]

5.10 Randomly gets the elements of the collection:

Srandmember key [Count]

5.11 POPs an element from the collection:

Spop Key

6 Ordered collection types

6.1 New Collections

Zadd key score member [score member ...]

Adds a fraction of an element and an element to an ordered set.

6.2 Get the score for an ordered collection:

Zscorekey Member

6.3 Gets the range of fractions in an ordered collection:

Zrange key start stop [Withscores]

Returns the set element in key in the order of the score from small to large;

Zrevrange key start stop [Withscores]

Returns the set element in key in the order of the fractions from large to small;

6.4 Gets the element that specifies the range of fractions:

Zrangebyscore key Minscorevalue Maxscorevalue [withscores] [limit Offsetcount]


6.5 Increase the score of an element:

Zincrby Key Increment member

Adds a score of increment to an element. If you add a score of 10 to an element in element scoreboard, then: Tom Zincrbyscoreboard

To lose a score, change it to a negative number.

6.6 Get the number of elements:

Zcard Key

6.7 Gets the number of elements in the atmosphere of the specified fraction:

Zcount Key min Max

6.8 Delete Elements by rank range:

Zremrangebyrank Key min Max

Min and Max refer to subscript, starting from 0.

6.9 Delete an element according to the specified fractional range:

Zremrangebyscore Key min Max

Min and Max refer to fractions.

6.10 Getting the element rank:

Zrange Key Member

Zrevrange Key Member

6.11 computes the intersection of an ordered set:

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.