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

MemcacheProfilerStorage.php

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