mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Very random micro-optimizations
This commit is contained in:
parent
ed0c5a4746
commit
63c0c2c75f
6 changed files with 32 additions and 20 deletions
|
@ -170,7 +170,7 @@ abstract class CacheEngine {
|
|||
$prefix = vsprintf($this->_groupPrefix, $this->groups());
|
||||
}
|
||||
|
||||
$key = Inflector::underscore(str_replace(array(DS, '/', '.'), '_', strval($key)));
|
||||
$key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace(array(DS, '/', '.'), '_', strval($key)))));
|
||||
return $prefix . $key;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,11 @@ class ApcEngine extends CacheEngine {
|
|||
* @see CacheEngine::__defaults
|
||||
*/
|
||||
public function init($settings = array()) {
|
||||
parent::init(array_merge(array('engine' => 'Apc', 'prefix' => Inflector::slug(APP_DIR) . '_'), $settings));
|
||||
if (!isset($settings['prefix'])) {
|
||||
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
|
||||
}
|
||||
$settings += array('engine' => 'Apc');
|
||||
parent::init($settings);
|
||||
return function_exists('apc_dec');
|
||||
}
|
||||
|
||||
|
|
|
@ -68,13 +68,16 @@ class FileEngine extends CacheEngine {
|
|||
* @return boolean True if the engine has been successfully initialized, false if not
|
||||
*/
|
||||
public function init($settings = array()) {
|
||||
parent::init(array_merge(
|
||||
array(
|
||||
'engine' => 'File', 'path' => CACHE, 'prefix' => 'cake_', 'lock' => true,
|
||||
'serialize' => true, 'isWindows' => false, 'mask' => 0664
|
||||
),
|
||||
$settings
|
||||
));
|
||||
$settings += array(
|
||||
'engine' => 'File',
|
||||
'path' => CACHE,
|
||||
'prefix' => 'cake_',
|
||||
'lock' => true,
|
||||
'serialize' => true,
|
||||
'isWindows' => false,
|
||||
'mask' => 0664
|
||||
);
|
||||
parent::init($settings);
|
||||
|
||||
if (DS === '\\') {
|
||||
$this->settings['isWindows'] = true;
|
||||
|
|
|
@ -66,19 +66,21 @@ class MemcacheEngine extends CacheEngine {
|
|||
if (!class_exists('Memcache')) {
|
||||
return false;
|
||||
}
|
||||
parent::init(array_merge(array(
|
||||
if (!isset($settings['prefix'])) {
|
||||
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
|
||||
}
|
||||
$settings += array(
|
||||
'engine' => 'Memcache',
|
||||
'prefix' => Inflector::slug(APP_DIR) . '_',
|
||||
'servers' => array('127.0.0.1'),
|
||||
'compress' => false,
|
||||
'persistent' => true
|
||||
), $settings)
|
||||
);
|
||||
parent::init($settings);
|
||||
|
||||
if ($this->settings['compress']) {
|
||||
$this->settings['compress'] = MEMCACHE_COMPRESSED;
|
||||
}
|
||||
if (!is_array($this->settings['servers'])) {
|
||||
if (is_string($this->settings['servers'])) {
|
||||
$this->settings['servers'] = array($this->settings['servers']);
|
||||
}
|
||||
if (!isset($this->_Memcache)) {
|
||||
|
|
|
@ -45,10 +45,11 @@ class WincacheEngine extends CacheEngine {
|
|||
* @see CacheEngine::__defaults
|
||||
*/
|
||||
public function init($settings = array()) {
|
||||
parent::init(array_merge(array(
|
||||
'engine' => 'Wincache',
|
||||
'prefix' => Inflector::slug(APP_DIR) . '_'),
|
||||
$settings));
|
||||
if (!isset($settings['prefix'])) {
|
||||
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
|
||||
}
|
||||
$settings += array('engine' => 'Wincache');
|
||||
parent::init($settings);
|
||||
return function_exists('wincache_ucache_info');
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,15 @@ class XcacheEngine extends CacheEngine {
|
|||
* @return boolean True if the engine has been successfully initialized, false if not
|
||||
*/
|
||||
public function init($settings = array()) {
|
||||
parent::init(array_merge(array(
|
||||
if (!isset($settings['prefix'])) {
|
||||
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
|
||||
}
|
||||
$settings += array(
|
||||
'engine' => 'Xcache',
|
||||
'prefix' => Inflector::slug(APP_DIR) . '_',
|
||||
'PHP_AUTH_USER' => 'user',
|
||||
'PHP_AUTH_PW' => 'password'
|
||||
), $settings)
|
||||
);
|
||||
parent::init($settings);
|
||||
return function_exists('xcache_info');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue