Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

memcache.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 2.35 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\cache\driver;
015   
016  if (!defined('PHPBB_ACM_MEMCACHE_PORT'))
017  {
018      define('PHPBB_ACM_MEMCACHE_PORT', 11211);
019  }
020   
021  if (!defined('PHPBB_ACM_MEMCACHE_COMPRESS'))
022  {
023      define('PHPBB_ACM_MEMCACHE_COMPRESS', false);
024  }
025   
026  if (!defined('PHPBB_ACM_MEMCACHE_HOST'))
027  {
028      define('PHPBB_ACM_MEMCACHE_HOST', 'localhost');
029  }
030   
031  if (!defined('PHPBB_ACM_MEMCACHE'))
032  {
033      //can define multiple servers with host1/port1,host2/port2 format
034      define('PHPBB_ACM_MEMCACHE', PHPBB_ACM_MEMCACHE_HOST . '/' . PHPBB_ACM_MEMCACHE_PORT);
035  }
036   
037  /**
038  * ACM for Memcached
039  */
040  class memcache extends \phpbb\cache\driver\memory
041  {
042      var $extension = 'memcache';
043   
044      var $memcache;
045      var $flags = 0;
046   
047      function __construct()
048      {
049          // Call the parent constructor
050          parent::__construct();
051   
052          $this->memcache = new \Memcache;
053          foreach (explode(',', PHPBB_ACM_MEMCACHE) as $u)
054          {
055              $parts = explode('/', $u);
056              $this->memcache->addServer(trim($parts[0]), trim($parts[1]));
057          }
058          $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0;
059      }
060   
061      /**
062      * {@inheritDoc}
063      */
064      function unload()
065      {
066          parent::unload();
067   
068          $this->memcache->close();
069      }
070   
071      /**
072      * {@inheritDoc}
073      */
074      function purge()
075      {
076          $this->memcache->flush();
077   
078          parent::purge();
079      }
080   
081      /**
082      * Fetch an item from the cache
083      *
084      * @access protected
085      * @param string $var Cache key
086      * @return mixed Cached data
087      */
088      function _read($var)
089      {
090          return $this->memcache->get($this->key_prefix . $var);
091      }
092   
093      /**
094      * Store data in the cache
095      *
096      * @access protected
097      * @param string $var Cache key
098      * @param mixed $data Data to store
099      * @param int $ttl Time-to-live of cached data
100      * @return bool True if the operation succeeded
101      */
102      function _write($var, $data, $ttl = 2592000)
103      {
104          if (!$this->memcache->replace($this->key_prefix . $var, $data, $this->flags, $ttl))
105          {
106              return $this->memcache->set($this->key_prefix . $var, $data, $this->flags, $ttl);
107          }
108          return true;
109      }
110   
111      /**
112      * Remove an item from the cache
113      *
114      * @access protected
115      * @param string $var Cache key
116      * @return bool True if the operation succeeded
117      */
118      function _delete($var)
119      {
120          return $this->memcache->delete($this->key_prefix . $var);
121      }
122  }
123