此包已被废弃且不再维护。未建议替代包。
此包最新版本(v1.1.1)没有可用的许可信息。

异步任务执行库

v1.1.1 2014-02-06 23:41 UTC

This package is not auto-updated.

Last update: 2020-01-24 14:52:32 UTC


README

允许将长时间运行或异步任务编写为任务并在各种排队机制上排队。

目前支持 BeanstalkAmazon SQS

Build Status

安装

要将sera添加到项目中,最简单的方法是使用 composer

{
    "require": {
        "99designs/sera": ">=1.0.0"
    }
}

用法

<?php

// a simple task
class MyTask extends Sera_Task_Abstract
{
	public static function create($params)
	{
		return new self($params);
	}

	public function execute()
	{
    my_long_running_function($this->_data);
	}
}

// a queue that connects to beanstalkd
$queue = new Sera_Queue_BeanstalkQueue("127.0.0.1");
$queue->select('llama_tasks');

// enqueue the task
$queue->enqueue(MyTask::create('some data'));

// normally this would be in a seperate process
$worker = new Sera_Queue_QueueWorker($queue);
$worker->execute();

版权

版权 (c) 2012 99designs 更多详情请见 LICENSE