SpecialLinkSearch: clean up munged query variable handling
[mediawiki.git] / includes / objectcache / MemcachedPhpBagOStuff.php
blob6fba61ba0f237a6a531df63302172ef6aa46ed92
1 <?php
2 /**
3 * Object caching using memcached.
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.
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.
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
20 * @file
21 * @ingroup Cache
24 /**
25 * A wrapper class for the pure-PHP memcached client, exposing a BagOStuff interface.
27 * @ingroup Cache
29 class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
31 /**
32 * Constructor.
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
42 * @param array $params
44 function __construct( $params ) {
45 parent::__construct( $params );
46 $params = $this->applyDefaultParams( $params );
48 $this->client = new MemCachedClientforWiki( $params );
49 $this->client->set_servers( $params['servers'] );
50 $this->client->set_debug( $params['debug'] );
53 /**
54 * @param bool $debug
56 public function setDebug( $debug ) {
57 $this->client->set_debug( $debug );
60 /**
61 * @param array $keys
62 * @return array
64 public function getMulti( array $keys ) {
65 $callback = array( $this, 'encodeKey' );
66 return $this->client->get_multi( array_map( $callback, $keys ) );
69 /**
70 * @param string $key
71 * @param int $value
72 * @return mixed
74 public function incr( $key, $value = 1 ) {
75 return $this->client->incr( $this->encodeKey( $key ), $value );
78 /**
79 * @param string $key
80 * @param int $value
81 * @return mixed
83 public function decr( $key, $value = 1 ) {
84 return $this->client->decr( $this->encodeKey( $key ), $value );