Beanstalkd的PHP客戶端程式庫
Beanstalk,一個高效能、輕量級的分散式記憶體佇列系統,最初設計的目的是想透過後台非同步執行耗時的任務來降低高容量Web應用系統的頁面存取延遲,支援過有9.5 million用戶的Facebook Causes應用。
後來開源,現在有PostRank大規模部署和使用,每天處理百萬級任務。 Beanstalkd是典型的類Memcached設計,協議和使用方式都是同樣的風格,所以使用過memcached的用戶會覺得Beanstalkd似曾相識。
高性能離不開非同步,非同步也離不開佇列,而其內部都是Producer-Comsumer模式的原理。
Beanstalkd的PHP客戶端程式庫
#!/usr/bin/env php <?php define('BASE_DIR', realpath(__DIR__.'/..')); define('PHAR_FILENAME', 'pheanstalk.phar'); define('PHAR_FULLPATH', BASE_DIR.'/'.PHAR_FILENAME); // ---------------------------------------- reexecute_if_phar_readonly($argv); delete_existing_pheanstalk_phar(); build_pheanstalk_phar(); verify_pheanstalk_phar(); exit(0); // ---------------------------------------- // See: http://www.php.net/manual/en/phar.configuration.php#ini.phar.readonly function reexecute_if_phar_readonly($argv) { if (ini_get('phar.readonly') && !in_array('--ignore-readonly', $argv)) { $command = sprintf( 'php -d phar.readonly=0 %s --ignore-readonly', implode($argv, ' ') ); echo "Phar configured readonly in php.ini; attempting to re-execute:\n"; echo "$command\n"; passthru($command, $exitStatus); exit($exitStatus); } } function delete_existing_pheanstalk_phar() { if (file_exists(PHAR_FULLPATH)) { printf("- Deleting existing %s\n", PHAR_FILENAME); unlink(PHAR_FULLPATH); } } function build_pheanstalk_phar() { printf("- Building %s from %s\n", PHAR_FILENAME, BASE_DIR); $phar = new Phar(PHAR_FULLPATH); $phar->buildFromDirectory(BASE_DIR); $phar->setStub( $phar->createDefaultStub('vendor/autoload.php') ); } function verify_pheanstalk_phar() { $phar = new Phar(PHAR_FULLPATH); printf("- %s built with %d files.\n", PHAR_FILENAME, $phar->count()); }
免責聲明
本站所有資源皆由網友貢獻或各大下載網站轉載。請自行檢查軟體的完整性!本站所有資源僅供學習參考。請不要將它們用於商業目的。否則,一切後果都由您負責!如有侵權,請聯絡我們刪除。聯絡方式:admin@php.cn
Hot Tools
熱門文章
崩壞:星穹鐵道 - 所有金色替罪羊謎題解決方案
18 Jan 2025
手游攻略
Tales Of Graces F 重製版:所有鎖定的寶箱密碼
18 Jan 2025
手游攻略
魯馬島:考古學家職業指南
03 Jan 2025
手游攻略
如何修復 KB5049622 在 Windows 11 中安裝失敗的問題?
15 Jan 2025
故障排查
魯瑪島:所有魯瑪蛋地點
05 Jan 2025
手游攻略