[HttpFoundation] Micro-optimisation.

This commit is contained in:
Drak 2012-03-30 17:22:48 +05:45
parent e18fcd852a
commit 54c5d5ed32
3 changed files with 30 additions and 21 deletions

View File

@ -51,13 +51,16 @@ class NativeMemcacheSessionHandler extends NativeSessionHandler
*/
protected function setOptions(array $options)
{
$validOptions = array(
'memcache.allow_failover', 'memcache.max_failover_attempts',
'memcache.chunk_size', 'memcache.default_port', 'memcache.hash_strategy',
'memcache.hash_function', 'memcache.protocol', 'memcache.redundancy',
'memcache.session_redundancy', 'memcache.compress_threshold',
'memcache.lock_timeout'
);
foreach ($options as $key => $value) {
if (in_array($key, array(
'memcache.allow_failover', 'memcache.max_failover_attempts',
'memcache.chunk_size', 'memcache.default_port', 'memcache.hash_strategy',
'memcache.hash_function', 'memcache.protocol', 'memcache.redundancy',
'memcache.session_redundancy', 'memcache.compress_threshold',
'memcache.lock_timeout'))) {
if (in_array($key, $validOptions)) {
ini_set($key, $value);
}
}

View File

@ -51,12 +51,15 @@ class NativeMemcachedSessionHandler extends NativeSessionHandler
*/
protected function setOptions(array $options)
{
$validOptions = array(
'memcached.sess_locking', 'memcached.sess_lock_wait',
'memcached.sess_prefix', 'memcached.compression_type',
'memcached.compression_factor', 'memcached.compression_threshold',
'memcached.serializer'
);
foreach ($options as $key => $value) {
if (in_array($key, array(
'memcached.sess_locking', 'memcached.sess_lock_wait',
'memcached.sess_prefix', 'memcached.compression_type',
'memcached.compression_factor', 'memcached.compression_threshold',
'memcached.serializer'))) {
if (in_array($key, $validOptions)) {
ini_set($key, $value);
}
}

View File

@ -261,17 +261,20 @@ class NativeSessionStorage implements SessionStorageInterface
*/
public function setOptions(array $options)
{
$validOptions = array(
'auto_start', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cookie_lifetime', 'cookie_path', 'cookie_secure',
'entropy_file', 'entropy_length', 'gc_divisor',
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
'hash_function', 'name', 'referer_check',
'serialize_handler', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags'
);
foreach ($options as $key => $value) {
if (in_array($key, array(
'auto_start', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cookie_lifetime', 'cookie_path', 'cookie_secure',
'entropy_file', 'entropy_length', 'gc_divisor',
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
'hash_function', 'name', 'referer_check',
'serialize_handler', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags'))) {
if (in_array($key, $validOptions)) {
ini_set('session.'.$key, $value);
}
}