mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
Bugfixes and more conversions to PHP 7
This commit is contained in:
parent
2cada68f41
commit
3a7ec4ecb0
100 changed files with 238 additions and 992 deletions
|
|
@ -43,13 +43,7 @@ class Redis implements \MailSo\Cache\DriverInterface
|
|||
*/
|
||||
private $sKeyPrefix;
|
||||
|
||||
/**
|
||||
* @param string $sHost = '127.0.0.1'
|
||||
* @param int $iPost = 6379
|
||||
* @param int $iExpire = 43200
|
||||
* @param string $sKeyPrefix = ''
|
||||
*/
|
||||
private function __construct($sHost = '127.0.0.1', $iPost = 6379, $iExpire = 43200, $sKeyPrefix = '')
|
||||
private function __construct(string $sHost = '127.0.0.1', int $iPost = 6379, int $iExpire = 43200, string $sKeyPrefix = '')
|
||||
{
|
||||
$this->sHost = $sHost;
|
||||
$this->iPost = $iPost;
|
||||
|
|
@ -85,45 +79,23 @@ class Redis implements \MailSo\Cache\DriverInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHost = '127.0.0.1'
|
||||
* @param int $iPost = 11211
|
||||
* @param int $iExpire = 43200
|
||||
* @param string $sKeyPrefix = ''
|
||||
*
|
||||
* @return \MailSo\Cache\Drivers\APC
|
||||
*/
|
||||
public static function NewInstance($sHost = '127.0.0.1', $iPost = 6379, $iExpire = 43200, $sKeyPrefix = '')
|
||||
public static function NewInstance(string $sHost = '127.0.0.1', int $iPost = 6379, int $iExpire = 43200, string $sKeyPrefix = '') : self
|
||||
{
|
||||
return new self($sHost, $iPost, $iExpire, $sKeyPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @param string $sValue
|
||||
*/
|
||||
public function Set($sKey, $sValue) : bool
|
||||
public function Set(string $sKey, string $sValue) : bool
|
||||
{
|
||||
return $this->oRedis ? $this->oRedis->setex($this->generateCachedKey($sKey), $this->iExpire, $sValue) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function Get($sKey)
|
||||
public function Get(string $sKey) : string
|
||||
{
|
||||
$sValue = $this->oRedis ? $this->oRedis->get($this->generateCachedKey($sKey)) : '';
|
||||
return \is_string($sValue) ? $sValue : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Delete($sKey)
|
||||
public function Delete(string $sKey) : void
|
||||
{
|
||||
if ($this->oRedis)
|
||||
{
|
||||
|
|
@ -131,12 +103,7 @@ class Redis implements \MailSo\Cache\DriverInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iTimeToClearInHours = 24
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function GC($iTimeToClearInHours = 24)
|
||||
public function GC(int $iTimeToClearInHours = 24) : bool
|
||||
{
|
||||
if (0 === $iTimeToClearInHours && $this->oRedis)
|
||||
{
|
||||
|
|
@ -146,12 +113,7 @@ class Redis implements \MailSo\Cache\DriverInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateCachedKey($sKey)
|
||||
private function generateCachedKey(string $sKey) : string
|
||||
{
|
||||
return $this->sKeyPrefix.\sha1($sKey);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue