mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-06-08 15:53:34 +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() {
|
protected function _setOptions() {
|
||||||
$this->_Memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
|
$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(
|
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'];
|
if ($serializer !== 'php' && !constant('Memcached::HAVE_' . strtoupper($serializer))) {
|
||||||
switch($this->settings['serialize']) {
|
throw new CacheException(
|
||||||
case 'igbinary':
|
__d('cake_dev', 'Memcached extension is not compiled with %s support', $serializer)
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_Memcached->setOption(Memcached::OPT_SERIALIZER, $serializer);
|
$this->_Memcached->setOption(Memcached::OPT_SERIALIZER, $this->_serializers[$serializer]);
|
||||||
|
|
||||||
// Check for Amazon ElastiCache instance
|
// Check for Amazon ElastiCache instance
|
||||||
if (defined('Memcached::OPT_CLIENT_MODE') && defined('Memcached::DYNAMIC_CLIENT_MODE')) {
|
if (defined('Memcached::OPT_CLIENT_MODE') && defined('Memcached::DYNAMIC_CLIENT_MODE')) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue