Vii. Redis Foundation Command---task queue

Source: Internet
Author: User

1. Advantage: Loose couplingeasy to scale, consumers can expand multiple, distributed across different servers
2, Lpush rpop
3, Brpop command and Rpop similar, the only difference: when there are no elements in the list, the Brpop command will always block the link, know that there are new elements to join
4. Brpop Key Timeouta timeout equal to 0 means that the wait time (in seconds) is not throttled, and if no element is blocked. Example: Brpop list 0
5, Brpop key 1block for 1 seconds and remove the data. The return value is an array, the first element is the key name, and the second element is the value. If there is no data, return nil127.0.0.1:6379> brpop List 0
1) "List"
2) "
(11.46s)
"
127.0.0.1:6379> brpop List 2
(nil)     
6. Priority Queue Blpop Queue:1 queue2:2 queue3:3 0if all have values, take precedence over the value of the queue2 queue
7. Subscribe to Subcribe Channel Channelno. Clients in a subscription state can use only four commands: Subscribe/unsubscribe/psubscribe/punsubscribeReading Messages ... (Press Ctrl-c to quit)
1) "Subscribe"
2) "Channel"
3) (integer) 1can subscribe to multiple message channels at the same time
127.0.0.1:6379> SUBSCRIBE channel1 channel2 channel3
Reading Messages ... (Press Ctrl-c to quit)
1) "Subscribe"
2) "Channel1"
3) (integer) 1
1) "Subscribe"
2) "Channel2"
3) (integer) 2
1) "Subscribe"
2) "Channel3"
3) (integer) 3
8. Release message publish channel Channelno message. The return value indicates the number of clients that received this messageYou can also cancel multiple message channels at the same time127.0.0.1:6379> PUBLISH Channel Hello
(integer) 1

9, Psubscribe channel1.? * Subscribe to the message for the specified rule. Support for GLOB style wildcard formatIf the a client subscribes to Psubscribe 1.1 and Psubscribe 1.? * The message,at this point the B client publishes a message to channel1.1, and a client receives 2 messages.

10, Punsubscribe * Can not unsubscribe channel.* rules, but must use Punsubscribe channel.* unsubscribe

11. Pipelineclients and Redis are linked using the TCP protocol. When sending commands to Redis and returning execution results, it needs to be transmitted over the network. One-to-one is called round-trip delay. You can use pipeline technology if you want to execute multiple commands without relying on the return value of each other. Send multiple commands to Redis at once, sending this set of commands together through a pipe command. Pipelines reduce the number of client-to-redis traffic and reduce round-trip latency. similar to batch processing.



     

Vii. Redis Foundation Command---task queue

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.