[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Object caching using memcached. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * http://www.gnu.org/copyleft/gpl.html 19 * 20 * @file 21 * @ingroup Cache 22 */ 23 24 /** 25 * A wrapper class for the pure-PHP memcached client, exposing a BagOStuff interface. 26 * 27 * @ingroup Cache 28 */ 29 class MemcachedPhpBagOStuff extends MemcachedBagOStuff { 30 31 /** 32 * Constructor. 33 * 34 * Available parameters are: 35 * - servers: The list of IP:port combinations holding the memcached servers. 36 * - debug: Whether to set the debug flag in the underlying client. 37 * - persistent: Whether to use a persistent connection 38 * - compress_threshold: The minimum size an object must be before it is compressed 39 * - timeout: The read timeout in microseconds 40 * - connect_timeout: The connect timeout in seconds 41 * 42 * @param array $params 43 */ 44 function __construct( $params ) { 45 $params = $this->applyDefaultParams( $params ); 46 47 $this->client = new MemCachedClientforWiki( $params ); 48 $this->client->set_servers( $params['servers'] ); 49 $this->client->set_debug( $params['debug'] ); 50 } 51 52 /** 53 * @param bool $debug 54 */ 55 public function setDebug( $debug ) { 56 $this->client->set_debug( $debug ); 57 } 58 59 /** 60 * @param array $keys 61 * @return array 62 */ 63 public function getMulti( array $keys ) { 64 $callback = array( $this, 'encodeKey' ); 65 return $this->client->get_multi( array_map( $callback, $keys ) ); 66 } 67 68 /** 69 * @param string $key 70 * @param int $timeout 71 * @return bool 72 */ 73 public function lock( $key, $timeout = 0 ) { 74 return $this->client->lock( $this->encodeKey( $key ), $timeout ); 75 } 76 77 /** 78 * @param string $key 79 * @return mixed 80 */ 81 public function unlock( $key ) { 82 return $this->client->unlock( $this->encodeKey( $key ) ); 83 } 84 85 /** 86 * @param string $key 87 * @param int $value 88 * @return mixed 89 */ 90 public function incr( $key, $value = 1 ) { 91 return $this->client->incr( $this->encodeKey( $key ), $value ); 92 } 93 94 /** 95 * @param string $key 96 * @param int $value 97 * @return mixed 98 */ 99 public function decr( $key, $value = 1 ) { 100 return $this->client->decr( $this->encodeKey( $key ), $value ); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |