mysql quickly synchronize data to redis

Since the work is sometimes necessary to mysql data synchronization to redis, with a strip of redis python library to go into too time-consuming, checked the information found can be quickly implemented by redis agreement.

A redis protocol format:

 

such as

 

Redis agreement was converted to the format:

 

II. By linux command sends protocol

 

# '-Pipe' is the use of the tunnel redis, can greatly improve efficiency

# '|' Represents data symbols command line pipe, incoming symbol to the left as the right argument

If you want to import data redis mysql, mysql statement can be used to piece together a plurality of redis protocol, then transmitted symbols by duct redis process.

First written statement mysql, into redis_protocol.sql in:

 

In the command line:

 

No error, then you can, and then redis-cli verify successful. I tried 140 000 Data import only a second or two very fast.

III. Attach the code to achieve a python

 

Guess you like

Origin www.cnblogs.com/myjason2/p/11021023.html