昨天写了一篇博文
身份证校验,检查身份证号码输入是否正确
外链网址已屏蔽
很多人担心性能问题,我后来想用C写一个扩展,还会有人说影响性能,一不做二不休,干脆mq到远程,通过负载均衡解决。
这里只是提供了一个 mysql 与 ZeroMQ 通信的插件,我并没有将身份证校验程序写出来。不过MQ的服务端可以使用很多语言实现,c,java, php,python,perl,ruby ..... 你自己选择一个熟悉的语言写吧。
下载地址 : 外链网址已屏蔽
mysql-zmq-plugin
ZeroMQ / ØMQ for MySQL
Build
cmake .
make && make install
Install & uninstall
drop function zmq_client;
drop function zmq_publish;
create function zmq_client returns string soname 'libzeromq.so';
create function zmq_publish returns string soname 'libzeromq.so';
mysql> SELECT * FROM `mysql`.`func` LIMIT 1000;
+--------------+-----+--------------+----------+
| name | ret | dl | type |
+--------------+-----+--------------+----------+
| image_crc32 | 0 | image.so | function |
| image_rename | 0 | image.so | function |
| image_move | 0 | image.so | function |
| image_remove | 0 | image.so | function |
| image_check | 0 | image.so | function |
| fifo_write | 0 | fifo.so | function |
| fifo_read | 0 | fifo.so | function |
| fifo_remove | 0 | fifo.so | function |
| fifo_create | 0 | fifo.so | function |
| zmq_publish | 0 | libzeromq.so | function |
| zmq_client | 0 | libzeromq.so | function |
+--------------+-----+--------------+----------+
11 rows in set (0.00 sec)
Test
编译zeromq server 测试程序
cd test
cmake .
make
./server
在mysql终端中运行测试SQL
mysql> select zmq_client('tcp://localhost:5555','Hello world!');
+---------------------------------------------------+
| zmq_client('tcp://localhost:5555','Hello world!') |
+---------------------------------------------------+
| Hello world! OK |
+---------------------------------------------------+
1 row in set (0.01 sec)
mysql> select zmq_client('tcp://localhost:5555',mobile) from demo;
+-------------------------------------------+
| zmq_client('tcp://localhost:5555',mobile) |
+-------------------------------------------+
| 13113668891 OK |
| 13113668892 OK |
| 13113668893 OK |
| 13322993040 OK |
| 13588997745 OK |
+-------------------------------------------+
5 rows in set (0.03 sec)