/** * Interceptor child method to handle the case where a Model or * Database object is being set since it's not supported by the * standard backend interface * * @param string $name * @param mixed $value * @return void */ public function setOption($name, $value) { if ($name == 'db_object') { $this->setDbObject($value); } else { parent::setOption($name, $value); } }
/** * Interceptor child method to handle the case where an Inner * Cache object is being set since it's not supported by the * standard backend interface * * @param string $name * @param mixed $value * @return void */ public function setOption($name, $value) { if ($name == 'tag_cache') { $this->setInnerCache($value); } else { parent::setOption($name, $value); } }
/** * Interceptor child method to handle the case where an Inner * Cache object is being set since it's not supported by the * standard backend interface * * @param string $name * @param mixed $value * @return Zend_Cache_Backend_Static */ public function setOption($name, $value) { if ($name == 'tag_cache') { $this->setInnerCache($value); } else { // See #ZF-12047 and #GH-91 if ($name == 'cache_file_umask') { trigger_error("'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", E_USER_NOTICE); $name = 'cache_file_perm'; } if ($name == 'cache_directory_umask') { trigger_error("'cache_directory_umask' is deprecated -> please use 'cache_directory_perm' instead", E_USER_NOTICE); $name = 'cache_directory_perm'; } parent::setOption($name, $value); } return $this; }
/** * Set an option * * @param string $name * @param mixed $value * @throws \Zend_Cache_Exception * @return void */ public function setOption($name, $value) { $this->_backend->setOption($name, $value); }
public function setOption($name, $value) { switch ($name) { case 'server': // explode list of server urls by "," if (!is_array($value)) { $value = explode(',', $value); // if array key "host" exists -> this is an only one server configuration } elseif (isset($value['host'])) { $value = array($value); } $serverList = array(); foreach ($value as $k => $server) { $serverArr = array(); // detect host:port given as array key if (is_string($k)) { $hostArr = explode(':', $k); $serverArr['host'] = $hostArr[0]; if (isset($hostArr[1])) { $serverArr['port'] = $hostArr[1]; } } // parse server url if (is_string($server)) { $serverUrlArr = @parse_url($server); if (!$serverUrl) { throw new Zend_Cache_Exception('Invalid server url given: ' . $server); } $serverArr['host'] = $serverUrl['host']; if (isset($serverUrl['port'])) { $serverArr['port'] = $serverUrl['port']; } if (isset($serverUrl['query'])) { $queryArr = array(); parse_str($serverUrl['query'], $queryArr); $serverArr += $queryArr; } } $normalizedServerOpts = $this->_normalizeServerOptions($serverArr); $serverKey = $normalizedServerOpts['host'] . ':' . $normalizedServerOpts['port']; $serverList[$serverKey] = $normalizedServerOpts; } $value = $serverList; if ($this->_memcached) { // TODO: check if a simple parameter change is enough or only a new server was added. $this->_memcached = null; } break; case 'persistent': if ($value) { $value = self::DEFAULT_PERSISTENT_ID; } else { $value = false; } // -> no break -> handle by persistent_id // -> no break -> handle by persistent_id case 'persistent_id': if (!$value) { $value = false; } else { $value = (string) $value; } if ($value !== $this->_options['persistent_id']) { $this->_memcached = null; } break; case 'distribution': $value = (int) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_DISTRIBUTION, $value); } break; case 'libketama_compatible': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, $value); } break; case 'buffer_writes': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_BUFFER_WRITES, $value); } break; case 'binary_protocol': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, $value); } break; case 'no_block': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_NO_BLOCK, $value); } break; case 'tcp_nodelay': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_TCP_NODELAY, $value); } break; case 'socket_send_size': $value = (int) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_SOCKET_SEND_SIZE, $value); } break; case 'socket_recv_size': $value = (int) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_SOCKET_RECV_SIZE, $value); } break; case 'compression': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_COMPRESSION, $value); } break; case 'serializer': if (is_int($value)) { $this->_serializerObject = null; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_SERIALIZER, $value); } } else { if (!$value instanceof Zend_Serializer_Adapter_AdapterInterface) { require_once 'Zend/Serializer.php'; $value = Zend_Serializer::factory($value); } $this->_serializerObject = $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_PHP); } } break; case 'hash_algo': $value = (int) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_HASH, $value); } break; case 'connect_timeout': $value = (double) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_CONNECT_TIMEOUT, $value * 1000); } break; case 'retry_timeout': $value = (int) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_RETRY_TIMEOUT, $value); } break; case 'send_timeout': $value = (double) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_SEND_TIMEOUT, $value * 1000); } break; case 'recv_timeout': $value = (double) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_RECV_TIMEOUT, $value * 1000); } break; case 'poll_timeout': $value = (double) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_POLL_TIMEOUT, $value * 1000); } break; case 'cache_dns_lookups': $value = (bool) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_CACHE_LOOKUPS, $value); } break; case 'server_failure_limit': $value = (int) $value; if ($this->_memcached) { $this->_memcached->setOption(Memcached::OPT_SERVER_FAILURE_LIMIT, $value); } break; } parent::setOption($name, $value); }