mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Improve serializer engine assignment code
This commit is contained in:
parent
85e5ef4d4e
commit
5d30cb1559
1 changed files with 8 additions and 23 deletions
|
@ -135,35 +135,20 @@ class MemcachedEngine extends CacheEngine {
|
|||
protected function _setOptions() {
|
||||
$this->_Memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
|
||||
|
||||
if (!isset($this->_serializers[$this->settings['serialize']])) {
|
||||
$serializer = strtolower($this->settings['serialize']);
|
||||
if (!isset($this->_serializers[$serializer])) {
|
||||
throw new CacheException(
|
||||
__d('cake_dev', '%s is not a valid serializer engine for Memcached', $this->settings['serialize'])
|
||||
__d('cake_dev', '%s is not a valid serializer engine for Memcached', $serializer)
|
||||
);
|
||||
}
|
||||
|
||||
$serializer = $this->_serializers['php'];
|
||||
switch($this->settings['serialize']) {
|
||||
case 'igbinary':
|
||||
if (Memcached::HAVE_IGBINARY) {
|
||||
$serializer = $this->_serializers['igbinary'];
|
||||
} else {
|
||||
throw new CacheException(
|
||||
__d('cake_dev', 'Memcached extension is not compiled with igbinary support')
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'json':
|
||||
if (Memcached::HAVE_JSON) {
|
||||
$serializer = $this->_serializers['json'];
|
||||
} else {
|
||||
throw new CacheException(
|
||||
__d('cake_dev', 'Memcached extension is not compiled with json support')
|
||||
);
|
||||
}
|
||||
break;
|
||||
if ($serializer !== 'php' && !constant('Memcached::HAVE_' . strtoupper($serializer))) {
|
||||
throw new CacheException(
|
||||
__d('cake_dev', 'Memcached extension is not compiled with %s support', $serializer)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_Memcached->setOption(Memcached::OPT_SERIALIZER, $serializer);
|
||||
$this->_Memcached->setOption(Memcached::OPT_SERIALIZER, $this->_serializers[$serializer]);
|
||||
|
||||
// Check for Amazon ElastiCache instance
|
||||
if (defined('Memcached::OPT_CLIENT_MODE') && defined('Memcached::DYNAMIC_CLIENT_MODE')) {
|
||||
|
|
Loading…
Add table
Reference in a new issue