1 Star 0 Fork 11

ThinkYoung/php-queue

forked from inhere/php-queue 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Queue.php 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
inhere 提交于 2018-03-07 11:13 +08:00 . remove dep inhere/library. add other package dep
<?php
/**
* Created by PhpStorm.
* User: inhere
* Date: 2017/5/29
* Time: 上午10:36
*/
namespace Inhere\Queue;
use Inhere\Queue\Driver\DbQueue;
use Inhere\Queue\Driver\PhpQueue;
use Inhere\Queue\Driver\RedisQueue;
use Inhere\Queue\Driver\ShmQueue;
use Inhere\Queue\Driver\SysVQueue;
/**
* Class Queue - queue factory
* @package Inhere\Queue
*/
final class Queue
{
const DRIVER_DB = 'db';
const DRIVER_PHP = 'php';
// const DRIVER_LDB = 'levelDb';
// const DRIVER_RDB = 'rocksDb';
const DRIVER_SHM = 'shm';
const DRIVER_SYSV = 'sysv';
const DRIVER_REDIS = 'redis';
/**
* driver map
* @var array
*/
private static $driverMap = [
'db' => DbQueue::class,
'php' => PhpQueue::class,
'sysv' => SysVQueue::class,
'shm' => ShmQueue::class,
'redis' => RedisQueue::class,
];
/**
* @param string $driver
* @param array $config
* @return QueueInterface
*/
public static function make(array $config = [], $driver = '')
{
if (!$driver && isset($config['driver'])) {
$driver = $config['driver'];
unset($config['driver']);
}
if ($driver && ($class = self::getDriverClass($driver))) {
return new $class($config);
}
return new PhpQueue($config);
}
/**
* @param $driver
* @return mixed|null
*/
public static function getDriverClass($driver)
{
return self::$driverMap[$driver] ?? null;
}
/**
* @return array
*/
public static function getDriverMap(): array
{
return self::$driverMap;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/thinkyoung/php-queue.git
git@gitee.com:thinkyoung/php-queue.git
thinkyoung
php-queue
php-queue
master

搜索帮助