php队列框架wanqueue/文件队列,可快速切换到reids/mysql等任何队列。开心/方便/简单。
运行 php wanqueue/console/queueserver.php 开启队列服务
//添加任务到队列
$que=new wanqueue\queue\queue();
$que->push(new wanqueue\jobs\email('18618300482@163.com','i love wanwan','i love you !'));
使用方法
push(new WanQueue\Jobs\Email('18618300482@163.com','i love wanwan','i love you !'));job示例
XYCMS建站系统PHP版非MVC框架,自己手写原生态普通代码,作为企业用,已经绰绰有余。软件运行效率中等,加入数据缓存后性能提高。假如用来学习,下载可以慢慢研究的,假如用来建站,可以选择购买商业版就行建站用。栏目类别:文章,人员信息,专题项目,招聘,下载,相册,单页【支持无限极分类】文章:可用作添加新闻,资讯,列表信息类栏目信息人员信息:可用作企业员工信息栏目内容添加或者维护专题项目:可用作企业
email=$email;
$this->title=$title;
$this->content=$content;
}
function handle()
{
// TODO: Implement handle() method.
echo 'email to :',$this->email,' theme : ',$this->title ,' send success !',"\n";
}
}redis驱动队列
queueName=$queueName;
$this->getRedisQueue();
}
/**
* 获取队列---redis版
*/
private function getRedisQueue(){
if($this->queue==null){
try {
$this->queue = new \Redis();
$this->queue->pconnect('127.0.0.1', 6379);
} catch (Exception $e) {
file_put_contents(date('Y-m-d').'-redis.log', date('Y-m-d H:i:s').' : '. $e->getMessage(), FILE_APPEND);
}
}
}
/**
* 获取队列-----文件版
*/
private function getQueue(){
$queue=__DIR__."/Queue/{$this->queueName}.queue";
if(!is_file($queue)){
return [];
}
return json_decode(file_get_contents($queue),true);
}
/**
* 队列持久化----文件版
*/
private function setQueue(){
if(!is_dir(__DIR__."/Queue")){
mkdir(__DIR__."/Queue");
}
file_put_contents(__DIR__."/Queue/{$this->queueName}.queue",json_encode($this->queue));
}
/**
* 入队
* @param $value
* @return int
*/
function push($value){
return $this->queue->rpush($this->queueName,serialize($value));
}
/**
* 出队
* @return mixed
*/
function pop(){
return unserialize($this->queue->lpop($this->queueName));
}
/**
* 从开始入队
* @param $value
* @return int
*/
function prePush($value){
return $this->queue->lpush($this->queueName,serialize($value));
}
/**
* 从末尾出队
* @return mixed
*/
function popL(){
return unserialize($this->queue->rpop($this->queueName));
}
/**
* 队列保存
*/
function __destruct()
{
// TODO: Implement __destruct() method.
//$this->setQueue();
}
}










