The project requires a scheduling module that schedules scheduled tasks, condition-triggered tasks, such as traffic. My design is: A scanner regularly scan the database in the non-start task, the task is sent to Gearman,gearman distributed to workers,worker distribution to determine the task trigger conditions, if the trigger conditions are met, the package task sent to Gearman, Gearman distributed to Workers,workers to perform the task.
Gearman the operating architecture:
Gearman's Client&worker API supports many languages and I need PHP. PHP is divided into two kinds, one is Gearman Extension, is the PHP extension, is a package of Libgearman C library extension, Using the. so extension to let PHP load, the approximate step is: Need to install Libgearman (this to install libevent and so on), and then use pecl install PHP Gearman extension, the other is Net_gearman, this is a pure PHP library, You can use pear to get down and use the words need require come in.
Here I also figure out the difference between pecl and pear:
Pear: PHP Extension Code package, all the extensions are in the form of PHP code, powerful, easy to install, even can be changed. When used, the include in the code can be used.
PECL: PHP is a standard extension that complements the functionality required in real-world development, all extensions need to be installed and configured in php.ini to restart PHP.
When I installed Gearman extension, I met n problems, I couldn't make it, I gave up, instead of Net_gearman.
Installation:
Pear Install Net_gearman
Will usually be decompressed here:
Php/lib/php/net/gearman
API documentation
I found a foreigner to write the Net_gearman tutorial, feel good, there are some examples. I ran through an example and then learned and tested each example.