Revert r88008 (add size difference to Special:Contributions) and its large group...
[lhc/web/wiklou.git] / includes / objectcache / HashBagOStuff.php
1 <?php
2
3 /**
4 * This is a test of the interface, mainly. It stores things in an associative
5 * array, which is not going to persist between program runs.
6 *
7 * @ingroup Cache
8 */
9 class HashBagOStuff extends BagOStuff {
10 var $bag;
11
12 function __construct() {
13 $this->bag = array();
14 }
15
16 protected function expire( $key ) {
17 $et = $this->bag[$key][1];
18
19 if ( ( $et == 0 ) || ( $et > time() ) ) {
20 return false;
21 }
22
23 $this->delete( $key );
24
25 return true;
26 }
27
28 function get( $key ) {
29 if ( !isset( $this->bag[$key] ) ) {
30 return false;
31 }
32
33 if ( $this->expire( $key ) ) {
34 return false;
35 }
36
37 return $this->bag[$key][0];
38 }
39
40 function set( $key, $value, $exptime = 0 ) {
41 $this->bag[$key] = array( $value, $this->convertExpiry( $exptime ) );
42 }
43
44 function delete( $key, $time = 0 ) {
45 if ( !isset( $this->bag[$key] ) ) {
46 return false;
47 }
48
49 unset( $this->bag[$key] );
50
51 return true;
52 }
53
54 function keys() {
55 return array_keys( $this->bag );
56 }
57 }
58