Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

MemcachedSessionHandler.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 2.81 KiB


 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   * Memcached based session storage handler based on the Memcached class
 016   * provided by the PHP memcached extension.
 017   *
 018   * @see https://php.net/memcached
 019   *
 020   * @author Drak <drak@zikula.org>
 021   */
 022  class MemcachedSessionHandler extends AbstractSessionHandler
 023  {
 024      private $memcached;
 025   
 026      /**
 027       * @var int Time to live in seconds
 028       */
 029      private $ttl;
 030   
 031      /**
 032       * @var string Key prefix for shared environments
 033       */
 034      private $prefix;
 035   
 036      /**
 037       * Constructor.
 038       *
 039       * List of available options:
 040       *  * prefix: The prefix to use for the memcached keys in order to avoid collision
 041       *  * expiretime: The time to live in seconds.
 042       *
 043       * @throws \InvalidArgumentException When unsupported options are passed
 044       */
 045      public function __construct(\Memcached $memcached, array $options = [])
 046      {
 047          $this->memcached = $memcached;
 048   
 049          if ($diff = array_diff(array_keys($options), ['prefix', 'expiretime'])) {
 050              throw new \InvalidArgumentException(sprintf('The following options are not supported "%s".', implode(', ', $diff)));
 051          }
 052   
 053          $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
 054          $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
 055      }
 056   
 057      /**
 058       * @return bool
 059       */
 060      public function close()
 061      {
 062          return $this->memcached->quit();
 063      }
 064   
 065      /**
 066       * {@inheritdoc}
 067       */
 068      protected function doRead($sessionId)
 069      {
 070          return $this->memcached->get($this->prefix.$sessionId) ?: '';
 071      }
 072   
 073      /**
 074       * @return bool
 075       */
 076      public function updateTimestamp($sessionId, $data)
 077      {
 078          $this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
 079   
 080          return true;
 081      }
 082   
 083      /**
 084       * {@inheritdoc}
 085       */
 086      protected function doWrite($sessionId, $data)
 087      {
 088          return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl);
 089      }
 090   
 091      /**
 092       * {@inheritdoc}
 093       */
 094      protected function doDestroy($sessionId)
 095      {
 096          $result = $this->memcached->delete($this->prefix.$sessionId);
 097   
 098          return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode();
 099      }
 100   
 101      /**
 102       * @return bool
 103       */
 104      public function gc($maxlifetime)
 105      {
 106          // not required here because memcached will auto expire the records anyhow.
 107          return true;
 108      }
 109   
 110      /**
 111       * Return a Memcached instance.
 112       *
 113       * @return \Memcached
 114       */
 115      protected function getMemcached()
 116      {
 117          return $this->memcached;
 118      }
 119  }
 120