123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- declare(strict_types=1);
- /**
- * This file is part of Hyperf.
- *
- * @link https://www.hyperf.io
- * @document https://hyperf.wiki
- * @contact group@hyperf.io
- * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
- */
- namespace Hyperf\Redis\Pool;
- use Hyperf\Di\Container;
- use Psr\Container\ContainerInterface;
- class PoolFactory
- {
- /**
- * @var RedisPool[]
- */
- protected array $pools = [];
- public function __construct(protected ContainerInterface $container)
- {
- }
- public function getPool(string $name): RedisPool
- {
- if (isset($this->pools[$name])) {
- return $this->pools[$name];
- }
- if ($this->container instanceof Container) {
- $pool = $this->container->make(RedisPool::class, ['name' => $name]);
- } else {
- $pool = new RedisPool($this->container, $name);
- }
- return $this->pools[$name] = $pool;
- }
- }
|