Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Jun 16, 2019
1 parent 218a2fa commit 819f146
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 48 deletions.
43 changes: 5 additions & 38 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

class Config extends SplBean
{
protected $host;
protected $port;
protected $host = '127.0.0.1';
protected $port = 6379;
protected $auth;
protected $options = [];
protected $serialize=false;
protected $timeout = 3;
protected $options = [
'serialize'=>true
];

/**
* @return mixed
Expand Down Expand Up @@ -78,37 +78,4 @@ public function setOptions(array $options): void
{
$this->options = $options;
}

/**
* @return int
*/
public function getTimeout(): int
{
return $this->timeout;
}

/**
* @param int $timeout
*/
public function setTimeout(int $timeout): void
{
$this->timeout = $timeout;
}

/**
* @return bool
*/
public function getSerialize(): bool
{
return $this->serialize;
}

/**
* @param bool $serialize
*/
public function setSerialize(bool $serialize): void
{
$this->serialize = $serialize;
}

}
3 changes: 2 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@


use EasySwoole\Component\Pool\PoolObjectInterface;
use Swoole\Coroutine\Redis;

class Connection extends \Swoole\Coroutine\Redis implements PoolObjectInterface
class Connection extends Redis implements PoolObjectInterface
{
function gc()
{
Expand Down
11 changes: 2 additions & 9 deletions src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use EasySwoole\Component\Pool\PoolConf;
use EasySwoole\Component\Pool\PoolManager;
use EasySwoole\Component\Singleton;
use EasySwoole\RedisPool\RedisPoolException;
use EasySwoole\Utility\Random;

class Redis
Expand Down Expand Up @@ -38,8 +37,8 @@ class '.$class.' extends AbstractPool {
protected function createObject()
{
$config = $this->getConfig()->getExtraConf();
$conn = new Connection();
$ret = $conn->connect($config->getHost(),$config->getPort(),$config->getSerialize());
$conn = new Connection($config->getOptions());
$ret = $conn->connect($config->getHost(),$config->getPort());
if(!$ret){
return;
}
Expand All @@ -49,11 +48,6 @@ protected function createObject()
if(!$ret){
return;
}
if(!empty($config->getOptions())){
foreach ($config->getOptions() as $key => $item){
$conn->setOption($key,$item);
}
}
return $conn;
}
}';
Expand Down Expand Up @@ -98,7 +92,6 @@ public function pool(string $name):?AbstractPool
if($item instanceof AbstractPool){
return $item;
}else{

$class = $item['class'];
$pool = PoolManager::getInstance()->getPool($class);
$this->list[$name] = $pool;
Expand Down

0 comments on commit 819f146

Please sign in to comment.