1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
- class NativeMemcacheSessionHandler extends NativeSessionHandler
- {
-
- public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', array $options = array())
- {
- if (!extension_loaded('memcache')) {
- throw new \RuntimeException('PHP does not have "memcache" session module registered');
- }
- if (null === $savePath) {
- $savePath = ini_get('session.save_path');
- }
- ini_set('session.save_handler', 'memcache');
- ini_set('session.save_path', $savePath);
- $this->setOptions($options);
- }
-
- protected function setOptions(array $options)
- {
- 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'))) {
- ini_set($key, $value);
- }
- }
- }
- }
|