forked from leftypol/leftypol
RedisCacheDriver.php: use CacheDriverTrait
This commit is contained in:
parent
84a22a788e
commit
b9a29927f3
1 changed files with 6 additions and 7 deletions
|
|
@ -5,18 +5,17 @@ defined('TINYBOARD') or exit;
|
|||
|
||||
|
||||
class RedisCacheDriver implements CacheDriver {
|
||||
use CacheDriverTrait;
|
||||
|
||||
private string $prefix;
|
||||
private \Redis $inner;
|
||||
|
||||
public function __construct(string $prefix, string $host, ?int $port, ?string $password, int $database) {
|
||||
$this->inner = new \Redis();
|
||||
if (str_starts_with($host, 'unix:') || str_starts_with($host, ':')) {
|
||||
$ret = \explode(':', $host);
|
||||
if (count($ret) < 2) {
|
||||
throw new \RuntimeException("Invalid unix socket path $host");
|
||||
}
|
||||
// Unix socket.
|
||||
$this->inner->connect($ret[1]);
|
||||
$maybe_unix = self::asUnixSocketPath($host);
|
||||
|
||||
if ($maybe_unix !== null) {
|
||||
$this->inner->connect($maybe_unix);
|
||||
} elseif ($port === null) {
|
||||
$this->inner->connect($host);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue