Resolve "Redis service" #1052

Merged
korina.cordero merged 6 commits from 206-redis-service into master 2019-05-27 02:06:20 +00:00
2 changed files with 26 additions and 5 deletions
Showing only changes of commit a166a5f09a - Show all commits

View file

@ -80,6 +80,9 @@ services:
$scheme: "%env(REDIS_CLIENT_SCHEME)%"
$host: "%env(REDIS_CLIENT_HOST)%"
$port: "%env(REDIS_CLIENT_PORT)%"
$cert_file: "%env(REDIS_CLIENT_CERTFILE)%"
$password: "%env(REDIS_CLIENT_PASSWORD)%"
$env_flag: "dev"
Catalyst\APIBundle\Security\APIKeyUserProvider:
arguments:

View file

@ -10,20 +10,38 @@ class RedisClient
protected $scheme;
protected $host;
protected $port;
protected $cert_file;
protected $password;
protected $env_flag;
public function __construct($scheme, $host, $port)
public function __construct($scheme, $host, $port, $cert_file, $password, $env_flag)
{
$this->scheme = $scheme;
$this->host = $host;
$this->port = $port;
$this->cert_file = $cert_file;
$this->password = $password;
$this->env_flag = $env_flag;
}
public function getRedisClient()
{
$this->redis = new PredisClient([
"scheme"=>$this->scheme,
"host"=>$this->host,
"port"=>$this->port]);
if ($this->env_flag == 'dev')
{
$this->redis = new PredisClient([
"scheme"=>$this->scheme,
"host"=>$this->host,
"port"=>$this->port]);
}
else
{
$this->redis = new PredisClient([
"scheme"=>$this->scheme,
"host"=>$this->host,
"port"=>$this->port,
"ssl"=>["cafile"=>$cert_file, "verify_peer"=>true],
"password"=>$password]);
}
return $this->redis;
}
}