[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\HttpKernel\Profiler; 13 14 @trigger_error('The '.__NAMESPACE__.'\MemcacheProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); 15 16 /** 17 * Memcache Profiler Storage. 18 * 19 * @author Andrej Hudec <pulzarraider@gmail.com> 20 * 21 * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. 22 * Use {@link FileProfilerStorage} instead. 23 */ 24 class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage 25 { 26 /** 27 * @var \Memcache 28 */ 29 private $memcache; 30 31 /** 32 * Internal convenience method that returns the instance of the Memcache. 33 * 34 * @return \Memcache 35 * 36 * @throws \RuntimeException 37 */ 38 protected function getMemcache() 39 { 40 if (null === $this->memcache) { 41 if (!preg_match('#^memcache://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { 42 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)); 43 } 44 45 $host = $matches[1] ?: $matches[2]; 46 $port = $matches[3]; 47 48 $memcache = new \Memcache(); 49 $memcache->addServer($host, $port); 50 51 $this->memcache = $memcache; 52 } 53 54 return $this->memcache; 55 } 56 57 /** 58 * Set instance of the Memcache. 59 * 60 * @param \Memcache $memcache 61 */ 62 public function setMemcache($memcache) 63 { 64 $this->memcache = $memcache; 65 } 66 67 /** 68 * {@inheritdoc} 69 */ 70 protected function getValue($key) 71 { 72 return $this->getMemcache()->get($key); 73 } 74 75 /** 76 * {@inheritdoc} 77 */ 78 protected function setValue($key, $value, $expiration = 0) 79 { 80 return $this->getMemcache()->set($key, $value, false, time() + $expiration); 81 } 82 83 /** 84 * {@inheritdoc} 85 */ 86 protected function delete($key) 87 { 88 return $this->getMemcache()->delete($key); 89 } 90 91 /** 92 * {@inheritdoc} 93 */ 94 protected function appendValue($key, $value, $expiration = 0) 95 { 96 $memcache = $this->getMemcache(); 97 98 if (method_exists($memcache, 'append')) { 99 // Memcache v3.0 100 if (!$result = $memcache->append($key, $value, false, $expiration)) { 101 return $memcache->set($key, $value, false, $expiration); 102 } 103 104 return $result; 105 } 106 107 // simulate append in Memcache <3.0 108 $content = $memcache->get($key); 109 110 return $memcache->set($key, $content.$value, false, $expiration); 111 } 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |