You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
787 B
PHP
38 lines
787 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Helper;
|
|
|
|
use Hyperf\Redis\RedisFactory;
|
|
use Hyperf\Redis\RedisProxy;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
|
|
/**
|
|
* Redis辅助类
|
|
*/
|
|
class Redis
|
|
{
|
|
/**
|
|
* @var RedisFactory
|
|
*/
|
|
private static $factory;
|
|
|
|
private static function getFactory(): RedisFactory
|
|
{
|
|
if (is_null(self::$factory)) {
|
|
self::$factory = ApplicationContext::getContainer()->get(RedisFactory::class);
|
|
}
|
|
return self::$factory;
|
|
}
|
|
|
|
public static function getInstance($poolName = 'default'): RedisProxy
|
|
{
|
|
return self::getFactory()->get($poolName);
|
|
}
|
|
|
|
public static function __callStatic($method, $args)
|
|
{
|
|
return call_user_func_array([self::getInstance(), $method], $args);
|
|
}
|
|
} |