Special case opus mime detction
[mediawiki.git] / includes / libs / objectcache / MemcachedPhpBagOStuff.php
blobe2d9d9394cf6ae98d6ae190652c1a723f2891b85
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 {
30 /**
31 * Available parameters are:
32 * - servers: The list of IP:port combinations holding the memcached servers.
33 * - debug: Whether to set the debug flag in the underlying client.
34 * - persistent: Whether to use a persistent connection
35 * - compress_threshold: The minimum size an object must be before it is compressed
36 * - timeout: The read timeout in microseconds
37 * - connect_timeout: The connect timeout in seconds
39 * @param array $params
41 function __construct( $params ) {
42 parent::__construct( $params );
43 $params = $this->applyDefaultParams( $params );
45 $this->client = new MemcachedClient( $params );
46 $this->client->set_servers( $params['servers'] );
47 $this->client->set_debug( $params['debug'] );
50 public function setDebug( $debug ) {
51 $this->client->set_debug( $debug );
54 public function getMulti( array $keys, $flags = 0 ) {
55 foreach ( $keys as $key ) {
56 $this->validateKeyEncoding( $key );
59 return $this->client->get_multi( $keys );
62 public function incr( $key, $value = 1 ) {
63 $this->validateKeyEncoding( $key );
65 return $this->client->incr( $key, $value );
68 public function decr( $key, $value = 1 ) {
69 $this->validateKeyEncoding( $key );
71 return $this->client->decr( $key, $value );