Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
MemcachedSessionHandler.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
013
014 /**
015 * MemcachedSessionHandler.
016 *
017 * Memcached based session storage handler based on the Memcached class
018 * provided by the PHP memcached extension.
019 *
020 * @see http://php.net/memcached
021 *
022 * @author Drak <drak@zikula.org>
023 */
024 class MemcachedSessionHandler implements \SessionHandlerInterface
025 {
026 /**
027 * @var \Memcached Memcached driver.
028 */
029 private $memcached;
030
031 /**
032 * @var int Time to live in seconds
033 */
034 private $ttl;
035
036 /**
037 * @var string Key prefix for shared environments.
038 */
039 private $prefix;
040
041 /**
042 * Constructor.
043 *
044 * List of available options:
045 * * prefix: The prefix to use for the memcached keys in order to avoid collision
046 * * expiretime: The time to live in seconds
047 *
048 * @param \Memcached $memcached A \Memcached instance
049 * @param array $options An associative array of Memcached options
050 *
051 * @throws \InvalidArgumentException When unsupported options are passed
052 */
053 public function __construct(\Memcached $memcached, array $options = array())
054 {
055 $this->memcached = $memcached;
056
057 if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) {
058 throw new \InvalidArgumentException(sprintf(
059 'The following options are not supported "%s"', implode(', ', $diff)
060 ));
061 }
062
063 $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
064 $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
065 }
066
067 /**
068 * {@inheritdoc}
069 */
070 public function open($savePath, $sessionName)
071 {
072 return true;
073 }
074
075 /**
076 * {@inheritdoc}
077 */
078 public function close()
079 {
080 return true;
081 }
082
083 /**
084 * {@inheritdoc}
085 */
086 public function read($sessionId)
087 {
088 return $this->memcached->get($this->prefix.$sessionId) ?: '';
089 }
090
091 /**
092 * {@inheritdoc}
093 */
094 public function write($sessionId, $data)
095 {
096 return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl);
097 }
098
099 /**
100 * {@inheritdoc}
101 */
102 public function destroy($sessionId)
103 {
104 return $this->memcached->delete($this->prefix.$sessionId);
105 }
106
107 /**
108 * {@inheritdoc}
109 */
110 public function gc($maxlifetime)
111 {
112 // not required here because memcached will auto expire the records anyhow.
113 return true;
114 }
115 }
116