mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 23:55:55 +08:00
Memcache support socket connections and Memcached class
This commit is contained in:
parent
4a39093042
commit
881528d2ee
|
@ -18,16 +18,6 @@ namespace MailSo\Cache\Drivers;
|
|||
*/
|
||||
class Memcache implements \MailSo\Cache\DriverInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sHost;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iPost;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -43,14 +33,12 @@ class Memcache implements \MailSo\Cache\DriverInterface
|
|||
*/
|
||||
private $sKeyPrefix;
|
||||
|
||||
function __construct(string $sHost = '127.0.0.1', int $iPost = 11211, int $iExpire = 43200, string $sKeyPrefix = '')
|
||||
function __construct(string $sHost = '127.0.0.1', int $iPort = 11211, int $iExpire = 43200, string $sKeyPrefix = '')
|
||||
{
|
||||
$this->sHost = $sHost;
|
||||
$this->iPost = $iPost;
|
||||
$this->iExpire = 0 < $iExpire ? $iExpire : 43200;
|
||||
|
||||
$this->oMem = new \Memcache;
|
||||
if (!$this->oMem->connect($this->sHost, $this->iPost))
|
||||
$this->oMem = \class_exists('Memcache',false) ? new \Memcache : new \Memcached;
|
||||
if (!$this->oMem->addServer($sHost, $this->iPort))
|
||||
{
|
||||
$this->oMem = null;
|
||||
}
|
||||
|
|
|
@ -694,11 +694,11 @@ class Actions
|
|||
break;
|
||||
|
||||
case ('MEMCACHE' === $sDriver || 'MEMCACHED' === $sDriver) &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('memcache_connect'):
|
||||
|
||||
(\class_exists('Memcache',false) || \class_exists('Memcached',false)):
|
||||
$sHost = $this->Config()->Get('labs', 'fast_cache_memcache_host', '127.0.0.1');
|
||||
$oDriver = new \MailSo\Cache\Drivers\Memcache(
|
||||
$this->Config()->Get('labs', 'fast_cache_memcache_host', '127.0.0.1'),
|
||||
(int)$this->Config()->Get('labs', 'fast_cache_memcache_port', 11211),
|
||||
$sHost,
|
||||
strpos($sHost, ':/') ? 0 : (int)$this->Config()->Get('labs', 'fast_cache_memcache_port', 11211),
|
||||
43200,
|
||||
$sKey
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue