diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 23588ed..623a83f 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -41,7 +41,9 @@ use Extend\Kuaidi100\Kuaidi; use Extend\Prescription\Prescription; use Extend\RegulatoryPlatform\regulatoryPlatform; use Extend\TencentIm\RecentContact; +use Extend\Wechat\Wechat; use Hyperf\Amqp\Producer; +use Hyperf\Cache\Cache; use Hyperf\DbConnection\Db; use Hyperf\Redis\Redis; use Hyperf\Utils\ApplicationContext; @@ -329,7 +331,5 @@ class TestController extends AbstractController } public function test_15(){ - $a = Mask::maskNameStr("gdxz123400000",2); - dump($a); } } \ No newline at end of file diff --git a/config/autoload/redis.php b/config/autoload/redis.php index 3180b62..01fae11 100644 --- a/config/autoload/redis.php +++ b/config/autoload/redis.php @@ -24,4 +24,18 @@ return [ 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), ], ], + 'prod' => [ + 'host' => "139.155.127.177", + 'auth' => "gdxz2022t&dj.d", + 'port' => 6379, + 'db' => (int) env('REDIS_DB', 0), + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 10, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), + ], + ], ]; diff --git a/extend/Wechat/Wechat.php b/extend/Wechat/Wechat.php index 564e771..15b9725 100644 --- a/extend/Wechat/Wechat.php +++ b/extend/Wechat/Wechat.php @@ -4,10 +4,12 @@ namespace Extend\Wechat; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; +use App\Factory\CacheFactory; use EasyWeChat\Kernel\Exceptions\BadResponseException; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient; use EasyWeChat\MiniApp\Application; +use Hyperf\Cache\Cache; use Hyperf\Utils\ApplicationContext; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -83,7 +85,7 @@ class Wechat $this->app = new Application($config); // 替换缓存 - $this->app->setCache(ApplicationContext::getContainer()->get(CacheInterface::class)); + $this->app->setCache(make(Cache::class,['driver' => 'prod'])); } catch (InvalidArgumentException $e) { throw new BusinessException('实例化EasyWeChat类失败:' . $e->getMessage(), HttpEnumCode::SERVER_ERROR);