Skip to content

Commit

Permalink
Merge pull request #2 from tioncico/master
Browse files Browse the repository at this point in the history
增加判断抛出异常
  • Loading branch information
kiss291323003 authored May 20, 2019
2 parents 5f9f101 + 204e3e5 commit a91cdae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use EasySwoole\Component\Pool\PoolConf;
use EasySwoole\Component\Pool\PoolManager;
use EasySwoole\Component\Singleton;
use EasySwoole\MysqliPool\RedisPoolException;
use EasySwoole\Utility\Random;

class Redis
Expand All @@ -19,7 +20,10 @@ class Redis
function register(string $name,Config $config):PoolConf
{
if(isset($this->list[$name])){
return $this->list[$name]['config'];
if(isset($this->list[$name])){
//已经注册,则抛出异常
throw new RedisPoolException("redis pool:{$name} is already been register");
}
}
/*
* 绕过去实现动态class
Expand Down
15 changes: 15 additions & 0 deletions src/RedisPoolException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Created by PhpStorm.
* User: tioncico
* Date: 19-5-19
* Time: 下午11:08
*/

namespace EasySwoole\MysqliPool;


class RedisPoolException extends \Exception
{

}

0 comments on commit a91cdae

Please sign in to comment.