1. 首页
  2. 考试认证
  3. 其它
  4. Zend Gearman中的Gearman工人快速入门指南

Zend Gearman中的Gearman工人快速入门指南

上传者: 2024-10-26 18:35:02上传 ZIP文件 5.26KB 热度 4次

Zend_Gearman 项目允许开发者像在 Zend 框架 中调用控制器一样,使用 Gearman 工人。源代码中包含一个快速入门指南,便于您轻松上手。以下是一个关于 Gearman_Worker 的简单示例代码。此代码文件位于 application/workers 文件夹下,并命名为 DemoWorker.php,类名为 DemoWorker。注意:GitHub 中的 textile 格式对于代码块中的空格处理不友好。示例代码


class DemoWorker extends Gearman_Worker {

    protected \$_registerFunction = 'demowork';

    protected \$_timeout = 10000; // 10 seconds

    protected \$_memory = 10; // 10 MB

    protected function ...

}

示例说明

  1. \$_registerFunction 指定了该工人的任务名称为 demowork

  2. \$_timeout 设置工人响应超时时间为 10 秒。

  3. \$_memory 设置最大内存占用为 10 MB。

下载地址
用户评论