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.
49 lines
919 B
PHTML
49 lines
919 B
PHTML
|
10 years ago
|
<?php
|
||
|
|
|
||
|
|
|
||
|
|
namespace App\Services;
|
||
|
|
|
||
|
|
use Predis\Client;
|
||
|
|
|
||
|
|
class RedisClient
|
||
|
|
{
|
||
|
|
public $client;
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$config = [
|
||
|
|
'scheme' => Config::get('redis_scheme'),
|
||
|
|
'password' => Config::get('redis_password'),
|
||
|
|
'host' => Config::get('redis_host'),
|
||
|
|
'port' => Config::get('redis_port'),
|
||
|
|
'database' => Config::get('redis_database'),
|
||
|
|
];
|
||
|
|
$this->client = new Client($config);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getClient()
|
||
|
|
{
|
||
|
|
return $this->client;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function get($key)
|
||
|
|
{
|
||
|
|
return $this->client->get($key);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function set($key, $value)
|
||
|
|
{
|
||
|
|
$this->client->set($key, $value);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setex($key, $time, $value)
|
||
|
|
{
|
||
|
|
$this->client->setex($key, $time, $value);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function del($key)
|
||
|
|
{
|
||
|
|
$this->client->del($key);
|
||
|
|
}
|
||
|
|
}
|