Skip to content

Commit

Permalink
调整config
Browse files Browse the repository at this point in the history
  • Loading branch information
FeiLiao-9 committed May 31, 2024
1 parent 2cff6de commit d6dfd43
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 19 deletions.
4 changes: 1 addition & 3 deletions src/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public function __construct()
*/
public function initConfig()
{
$config = require_once __DIR__ . '/config.php';

$this->config = $config;
$this->config = (new Config())->toArray();
}

/**
Expand Down
76 changes: 60 additions & 16 deletions src/config.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,74 @@
<?php

return [
'base_url' => 'https://sms.crmeb.net/api/v2',
namespace Crmeb\Yihaotong;

'base_cache_prefix' => 'sms-crmeb-yihaotong-',
/**
*
*/
class Config
{

'base_cache_timeout' => 300,
protected $baseUrl = 'https://sms.crmeb.net/api/v2';

'expires' => 3600,
protected $baseCachePrefix = 'sms-crmeb-yihaotong-';

'redis' => [
// 服务器地址
protected $baseCacheTimeout = 300;

protected $expires = 3600;

protected $redis = [
'host' => '127.0.0.1',
// 端口
'port' => '6379',
// 密码
'password' => '',
// 缓存有效期 0表示永久缓存
'expire' => 0,
// 缓存前缀
'prefix' => '',
// 缓存标签前缀
'tag_prefix' => '',
// 数据库 0号数据库
'select' => 0,

'timeout' => 0
],
];
];

public function setBaseUrl(string $baseUrl)
{
$this->baseUrl = $baseUrl;
return $this;
}

public function setBaseCachePrefix(string $baseCachePrefix)
{
$this->baseCachePrefix = $baseCachePrefix;
return $this;
}

public function setBaseCacheTimeout(int $baseCacheTimeout)
{
$this->baseCacheTimeout = $baseCacheTimeout;
return $this;
}

public function setExpires(int $expires)
{
$this->expires = $expires;
return $this;
}

public function setRedis(array $redis)
{
$this->redis = $redis;
return $this;
}

/**
* @return array
*/
public function toArray()
{
return [
'base_url' => $this->baseUrl,
'base_cache_prefix' => $this->baseCachePrefix,
'base_cache_timeout' => $this->baseCacheTimeout,
'expires' => $this->expires,
'redis' => $this->redis,
];
}
}

0 comments on commit d6dfd43

Please sign in to comment.