mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Rename APC to APCU
Drop unused APP_REQUEST_RND
This commit is contained in:
parent
f44515fa5b
commit
9859bab9c3
|
@ -10,6 +10,9 @@
|
|||
// Uncomment to enable multiple domain installation.
|
||||
//define('MULTIDOMAIN', 1);
|
||||
|
||||
// Uncomment to disable APCU.
|
||||
//define('APP_USE_APCU_CACHE', false);
|
||||
|
||||
/**
|
||||
* Custom 'data' folder path
|
||||
* @return string
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MailSo\Cache\Drivers;
|
|||
* @package Cache
|
||||
* @subpackage Drivers
|
||||
*/
|
||||
class APC implements \MailSo\Cache\DriverInterface
|
||||
class APCU implements \MailSo\Cache\DriverInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -35,25 +35,25 @@ class APC implements \MailSo\Cache\DriverInterface
|
|||
|
||||
public function Set(string $sKey, string $sValue) : bool
|
||||
{
|
||||
return \apc_store($this->generateCachedKey($sKey), (string) $sValue);
|
||||
return \apcu_store($this->generateCachedKey($sKey), (string) $sValue);
|
||||
}
|
||||
|
||||
public function Get(string $sKey) : string
|
||||
{
|
||||
$sValue = \apc_fetch($this->generateCachedKey($sKey));
|
||||
$sValue = \apcu_fetch($this->generateCachedKey($sKey));
|
||||
return \is_string($sValue) ? $sValue : '';
|
||||
}
|
||||
|
||||
public function Delete(string $sKey) : void
|
||||
{
|
||||
\apc_delete($this->generateCachedKey($sKey));
|
||||
\apcu_delete($this->generateCachedKey($sKey));
|
||||
}
|
||||
|
||||
public function GC(int $iTimeToClearInHours = 24) : bool
|
||||
{
|
||||
if (0 === $iTimeToClearInHours)
|
||||
{
|
||||
return \apc_clear_cache('user');
|
||||
return \apcu_clear_cache('user');
|
||||
}
|
||||
|
||||
return false;
|
|
@ -686,9 +686,9 @@ class Actions
|
|||
$oDriver = new \MailSo\Cache\Drivers\File(APP_PRIVATE_DATA . 'cache', $sKey);
|
||||
break;
|
||||
|
||||
case ('APC' === $sDriver || 'APCU' === $sDriver) &&
|
||||
case ('APCU' === $sDriver) &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled(array(
|
||||
'apc_store', 'apc_fetch', 'apc_delete', 'apc_clear_cache')):
|
||||
'apcu_store', 'apcu_fetch', 'apcu_delete', 'apcu_clear_cache')):
|
||||
|
||||
$oDriver = new \MailSo\Cache\Drivers\APC($sKey);
|
||||
break;
|
||||
|
@ -795,7 +795,7 @@ class Actions
|
|||
);
|
||||
|
||||
$this->oLogger->Write(
|
||||
'[APC:' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('apc_fetch') ? 'on' : 'off') .
|
||||
'[APCU:' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('apcu_fetch') ? 'on' : 'off') .
|
||||
'][MB:' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding') ? 'on' : 'off') .
|
||||
'][PDO:' . (\class_exists('PDO') ? (\implode(',', \Pdo::getAvailableDrivers()) ?: '~') : 'off') .
|
||||
'][Streams:' . \implode(',', \stream_get_transports()) .
|
||||
|
|
|
@ -42,7 +42,7 @@ abstract class AbstractConfig
|
|||
$this->aData = $this->defaultValues();
|
||||
|
||||
$this->bUseApcCache = APP_USE_APC_CACHE &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled(array('apc_fetch', 'apc_store'));
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled(array('apcu_fetch', 'apcu_store'));
|
||||
}
|
||||
|
||||
protected abstract function defaultValues() : array;
|
||||
|
@ -116,10 +116,10 @@ abstract class AbstractConfig
|
|||
{
|
||||
$sKey = $this->cacheKey();
|
||||
|
||||
$sTimeHash = \apc_fetch($sKey.'time');
|
||||
$sTimeHash = \apcu_fetch($sKey.'time');
|
||||
if ($sTimeHash && $sTimeHash === \md5($iMTime.'/'.$iATime))
|
||||
{
|
||||
$aFetchData = \apc_fetch($sKey.'data');
|
||||
$aFetchData = \apcu_fetch($sKey.'data');
|
||||
if (\is_array($aFetchData))
|
||||
{
|
||||
$this->aData = $aFetchData;
|
||||
|
@ -146,8 +146,8 @@ abstract class AbstractConfig
|
|||
{
|
||||
$sKey = $this->cacheKey();
|
||||
|
||||
\apc_store($sKey.'time', \md5($iMTime.'/'.$iATime));
|
||||
\apc_store($sKey.'data', $this->aData);
|
||||
\apcu_store($sKey.'time', \md5($iMTime.'/'.$iATime));
|
||||
\apcu_store($sKey.'data', $this->aData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ abstract class AbstractConfig
|
|||
{
|
||||
$sKey = $this->cacheKey();
|
||||
|
||||
\apc_delete($sKey.'time');
|
||||
\apc_delete($sKey.'data');
|
||||
\apcu_delete($sKey.'time');
|
||||
\apcu_delete($sKey.'data');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
|
|||
*/
|
||||
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
|
||||
{
|
||||
return !!\apc_store($this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
|
||||
return !!\apcu_store($this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
|
|||
public function Get($oAccount, int $iStorageType, string $sKey, $mDefault = false)
|
||||
{
|
||||
$bValue = false;
|
||||
$mValue = \apc_fetch($this->generateFileName($oAccount, $iStorageType, $sKey), $bValue);
|
||||
$mValue = \apcu_fetch($this->generateFileName($oAccount, $iStorageType, $sKey), $bValue);
|
||||
if (!$bValue)
|
||||
{
|
||||
$mValue = $mDefault;
|
||||
|
@ -35,7 +35,7 @@ class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
|
|||
*/
|
||||
public function Clear($oAccount, int $iStorageType, string $sKey) : bool
|
||||
{
|
||||
\apc_delete($this->generateFileName($oAccount, $iStorageType, $sKey));
|
||||
\apcu_delete($this->generateFileName($oAccount, $iStorageType, $sKey));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
if (defined('APP_VERSION'))
|
||||
{
|
||||
if (!defined('APP_REQUEST_RND'))
|
||||
if (!defined('APP_VERSION_ROOT_PATH'))
|
||||
{
|
||||
if (function_exists('sys_getloadavg')) {
|
||||
$load = sys_getloadavg();
|
||||
|
@ -25,11 +25,8 @@
|
|||
ini_set('register_globals', 0);
|
||||
ini_set('zend.ze1_compatibility_mode', 0);
|
||||
|
||||
define('APP_REQUEST_RND', function_exists('uuid_create') ? md5(uuid_create(UUID_TYPE_DEFAULT)) : bin2hex(random_bytes(16)));
|
||||
define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'snappymail/v/'.APP_VERSION.'/');
|
||||
|
||||
define('APP_USE_APC_CACHE', true);
|
||||
|
||||
// "img-src https:" is allowed due to remote images in e-mails
|
||||
define('APP_DEFAULT_CSP', "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data: https: http:; style-src 'self' 'unsafe-inline'");
|
||||
|
||||
|
@ -57,6 +54,8 @@
|
|||
include_once APP_INDEX_ROOT_PATH.'include.php';
|
||||
}
|
||||
|
||||
defined('APP_USE_APCU_CACHE') || define('APP_USE_APCU_CACHE', true);
|
||||
|
||||
$sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath;
|
||||
define('APP_DATA_FOLDER_PATH', 0 === strlen($sCustomDataPath) ? APP_INDEX_ROOT_PATH.'data/' : $sCustomDataPath.'/');
|
||||
unset($sCustomDataPath);
|
||||
|
|
Loading…
Reference in a new issue