Merge "Revert "Remove old compat methods/functions for mb_ functions""
[mediawiki.git] / includes / objectcache / WinCacheBagOStuff.php
blob4fd3cf4fea757b836e638af05b398e9b6112dd78
1 <?php
2 /**
3 * Object caching using WinCache.
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 * Wrapper for WinCache object caching functions; identical interface
26 * to the APC wrapper
28 * @ingroup Cache
30 class WinCacheBagOStuff extends BagOStuff {
32 /**
33 * Get a value from the WinCache object cache
35 * @param $key String: cache key
36 * @return mixed
38 public function get( $key ) {
39 $val = wincache_ucache_get( $key );
41 if ( is_string( $val ) ) {
42 $val = unserialize( $val );
45 return $val;
48 /**
49 * Store a value in the WinCache object cache
51 * @param $key String: cache key
52 * @param $value Mixed: object to store
53 * @param $expire Int: expiration time
54 * @return bool
56 public function set( $key, $value, $expire = 0 ) {
57 $result = wincache_ucache_set( $key, serialize( $value ), $expire );
59 /* wincache_ucache_set returns an empty array on success if $value
60 was an array, bool otherwise */
61 return ( is_array( $result ) && $result === array() ) || $result;
64 /**
65 * Remove a value from the WinCache object cache
67 * @param $key String: cache key
68 * @param $time Int: not used in this implementation
69 * @return bool
71 public function delete( $key, $time = 0 ) {
72 wincache_ucache_delete( $key );
74 return true;
77 public function keys() {
78 $info = wincache_ucache_info();
79 $list = $info['ucache_entries'];
80 $keys = array();
82 if ( is_null( $list ) ) {
83 return array();
86 foreach ( $list as $entry ) {
87 $keys[] = $entry['key_name'];
90 return $keys;