Merge "Add support for mulitpart mime email to email sending code"
[lhc/web/wiklou.git] / includes / objectcache / WinCacheBagOStuff.php
1 <?php
2 /**
3 * Object caching using WinCache.
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 * Wrapper for WinCache object caching functions; identical interface
26 * to the APC wrapper
27 *
28 * @ingroup Cache
29 */
30 class WinCacheBagOStuff extends BagOStuff {
31
32 /**
33 * Get a value from the WinCache object cache
34 *
35 * @param $key String: cache key
36 * @return mixed
37 */
38 public function get( $key ) {
39 $val = wincache_ucache_get( $key );
40
41 if ( is_string( $val ) ) {
42 $val = unserialize( $val );
43 }
44
45 return $val;
46 }
47
48 /**
49 * Store a value in the WinCache object cache
50 *
51 * @param $key String: cache key
52 * @param $value Mixed: object to store
53 * @param $expire Int: expiration time
54 * @return bool
55 */
56 public function set( $key, $value, $expire = 0 ) {
57 $result = wincache_ucache_set( $key, serialize( $value ), $expire );
58
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;
62 }
63
64 /**
65 * Remove a value from the WinCache object cache
66 *
67 * @param $key String: cache key
68 * @param $time Int: not used in this implementation
69 * @return bool
70 */
71 public function delete( $key, $time = 0 ) {
72 wincache_ucache_delete( $key );
73
74 return true;
75 }
76
77 /**
78 * @return Array
79 */
80 public function keys() {
81 $info = wincache_ucache_info();
82 $list = $info['ucache_entries'];
83 $keys = array();
84
85 if ( is_null( $list ) ) {
86 return array();
87 }
88
89 foreach ( $list as $entry ) {
90 $keys[] = $entry['key_name'];
91 }
92
93 return $keys;
94 }
95 }