mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
[snappymail] Improve Redis support
By using a connection URL, it is possible to support all Predis features, like passwords, unix sockets, database selection, etc. Tested with TCP and unix socket connections. Closes #113
This commit is contained in:
parent
cc03546484
commit
465e4b32ee
3 changed files with 6 additions and 17 deletions
|
|
@ -21,12 +21,7 @@ class Redis implements \MailSo\Cache\DriverInterface
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $sHost;
|
private $sUrl;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $iPost;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
|
|
@ -43,20 +38,16 @@ class Redis implements \MailSo\Cache\DriverInterface
|
||||||
*/
|
*/
|
||||||
private $sKeyPrefix;
|
private $sKeyPrefix;
|
||||||
|
|
||||||
function __construct(string $sHost = '127.0.0.1', int $iPost = 6379, int $iExpire = 43200, string $sKeyPrefix = '')
|
function __construct(string $sUrl = 'redis://127.0.0.1:6379', int $iExpire = 43200, string $sKeyPrefix = '')
|
||||||
{
|
{
|
||||||
$this->sHost = $sHost;
|
$this->sUrl = $sUrl;
|
||||||
$this->iPost = $iPost;
|
|
||||||
$this->iExpire = 0 < $iExpire ? $iExpire : 43200;
|
$this->iExpire = 0 < $iExpire ? $iExpire : 43200;
|
||||||
|
|
||||||
$this->oRedis = null;
|
$this->oRedis = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->oRedis = new \Predis\Client('unix:' === substr($sHost, 0, 5) ? $sHost : array(
|
$this->oRedis = new \Predis\Client($sUrl);
|
||||||
'host' => $sHost,
|
|
||||||
'port' => $iPost
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->oRedis->connect();
|
$this->oRedis->connect();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -706,8 +706,7 @@ class Actions
|
||||||
|
|
||||||
case 'REDIS' === $sDriver && \class_exists('Predis\Client'):
|
case 'REDIS' === $sDriver && \class_exists('Predis\Client'):
|
||||||
$oDriver = new \MailSo\Cache\Drivers\Redis(
|
$oDriver = new \MailSo\Cache\Drivers\Redis(
|
||||||
$this->Config()->Get('labs', 'fast_cache_redis_host', '127.0.0.1'),
|
$this->Config()->Get('labs', 'fast_cache_redis_url', 'redis://127.0.0.1:6379'),
|
||||||
(int)$this->Config()->Get('labs', 'fast_cache_redis_port', 6379),
|
|
||||||
43200,
|
43200,
|
||||||
$sKey
|
$sKey
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -367,8 +367,7 @@ Enables caching in the system'),
|
||||||
'http_client_ip_check_proxy' => array(false),
|
'http_client_ip_check_proxy' => array(false),
|
||||||
'fast_cache_memcache_host' => array('127.0.0.1'),
|
'fast_cache_memcache_host' => array('127.0.0.1'),
|
||||||
'fast_cache_memcache_port' => array(11211),
|
'fast_cache_memcache_port' => array(11211),
|
||||||
'fast_cache_redis_host' => array('127.0.0.1'),
|
'fast_cache_redis_url' => array('redis://127.0.0.1:6379'),
|
||||||
'fast_cache_redis_port' => array(6379),
|
|
||||||
'use_local_proxy_for_external_images' => array(true),
|
'use_local_proxy_for_external_images' => array(true),
|
||||||
'detect_image_exif_orientation' => array(true),
|
'detect_image_exif_orientation' => array(true),
|
||||||
'cookie_default_path' => array(''),
|
'cookie_default_path' => array(''),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue