Redis implementation of distributed queue Analysis _redis

Source: Internet
Author: User
Tags redis install redis

What is Redis?

Redis is a simple, efficient, distributed, memory-based cache tool.

Assuming a good server, provide key-value caching services over a network connection (similar to a database).

Simple, is the outstanding characteristic of Redis.

Simple to ensure that the core functions of stability and excellence.

Installation and configuration of Redis

Under Linux system:

Apt-get Install Redis-server

Under Windows:

Download link

Download the install MSI file just fine.

Configuring Master-Slave synchronization

You need to implement a distributed queue, at least one master (192.168.45.1) and one slave (192.168.45.130)

Linux default configuration file in/etc/redis/redis.conf

Master configuration:

bind 127.0.0.1

Slave configuration:

slaveof  192.168.45.1 6379

Then you can start the redis-server on each host separately.

Message Queuing mode

Pictures from the network, invasion and deletion

Use the Redis list type to save the data, and the queue takes the left-right out mode to guarantee the order of the queue messages.

Manipulating Redis data using Python

Import Redis

r= Redis. Redis (host= ' localhost ', port=6379, db=0) r.set ('
user ', ' Ioiogoo ') r.get ('
user ')
r.lpush (' queue:1 ', ' Task1 ')
r.brpop (' Queue:1 ', 3)

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

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.