1 Star 0 Fork 11

东方皓/php-queue

forked from inhere/php-queue 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
Queue.php 1.46 KB
Copy Edit Raw Blame History
inhere authored 2017-06-11 22:45 +08:00 . some logic update. bug fixed
<?php
/**
* Created by PhpStorm.
* User: inhere
* Date: 2017/5/29
* Time: 上午10:36
*/
namespace inhere\queue;
/**
* 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/royalwang/php-queue.git
git@gitee.com:royalwang/php-queue.git
royalwang
php-queue
php-queue
master

Search