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

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

MemcachedProfilerStorage.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.41 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\HttpKernel\Profiler;
 013   
 014  /**
 015   * Memcached Profiler Storage
 016   *
 017   * @author Andrej Hudec <pulzarraider@gmail.com>
 018   */
 019  class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage
 020  {
 021      /**
 022       * @var \Memcached
 023       */
 024      private $memcached;
 025   
 026      /**
 027       * Internal convenience method that returns the instance of the Memcached
 028       *
 029       * @return \Memcached
 030       *
 031       * @throws \RuntimeException
 032       */
 033      protected function getMemcached()
 034      {
 035          if (null === $this->memcached) {
 036              if (!preg_match('#^memcached://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) {
 037                  throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcached with an invalid dsn "%s". The expected format is "memcached://[host]:port".', $this->dsn));
 038              }
 039   
 040              $host = $matches[1] ?: $matches[2];
 041              $port = $matches[3];
 042   
 043              $memcached = new \Memcached();
 044   
 045              // disable compression to allow appending
 046              $memcached->setOption(\Memcached::OPT_COMPRESSION, false);
 047   
 048              $memcached->addServer($host, $port);
 049   
 050              $this->memcached = $memcached;
 051          }
 052   
 053          return $this->memcached;
 054      }
 055   
 056      /**
 057       * Set instance of the Memcached
 058       *
 059       * @param \Memcached $memcached
 060       */
 061      public function setMemcached($memcached)
 062      {
 063          $this->memcached = $memcached;
 064      }
 065   
 066      /**
 067       * {@inheritdoc}
 068       */
 069      protected function getValue($key)
 070      {
 071          return $this->getMemcached()->get($key);
 072      }
 073   
 074      /**
 075       * {@inheritdoc}
 076       */
 077      protected function setValue($key, $value, $expiration = 0)
 078      {
 079          return $this->getMemcached()->set($key, $value, time() + $expiration);
 080      }
 081   
 082      /**
 083       * {@inheritdoc}
 084       */
 085      protected function delete($key)
 086      {
 087          return $this->getMemcached()->delete($key);
 088      }
 089   
 090      /**
 091       * {@inheritdoc}
 092       */
 093      protected function appendValue($key, $value, $expiration = 0)
 094      {
 095          $memcached = $this->getMemcached();
 096   
 097          if (!$result = $memcached->append($key, $value)) {
 098              return $memcached->set($key, $value, $expiration);
 099          }
 100   
 101          return $result;
 102      }
 103  }
 104