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
863 B
PHTML

5 years ago
<?php
namespace Base\Tool;
use Redis as Handler;
class Redis
{
private static $handler;
public static function getHandler()
{
if(self::$handler == null) {
self::$handler = self::createHandler();
}
return self::$handler;
}
private static function createHandler()
{
$host = C('REDIS_HOST', null, '127.0.0.1');
$port = C('REDIS_PORT', null, 6379);
$timeout = C('REDIS_TIMEOUT', null, 300);
$auth = C('REDIS_AUTH');
$handler = new Handler();
$handler->connect($host, $port, $timeout);
if($auth !== null) {
$handler->auth($auth);
}
return $handler;
}
public static function __callStatic($method, $arguments)
{
return call_user_func_array([self::getHandler(), $method], $arguments);
}
}