* changed display function for length to Linker::formatRevisionSize
[mediawiki.git] / includes / objectcache / HashBagOStuff.php
blob36773306cec8eb8a6bb463c3cd4d977bfff51be4
1 <?php
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.
7 * @ingroup Cache
8 */
9 class HashBagOStuff extends BagOStuff {
10 var $bag;
12 function __construct() {
13 $this->bag = array();
16 protected function expire( $key ) {
17 $et = $this->bag[$key][1];
19 if ( ( $et == 0 ) || ( $et > time() ) ) {
20 return false;
23 $this->delete( $key );
25 return true;
28 function get( $key ) {
29 if ( !isset( $this->bag[$key] ) ) {
30 return false;
33 if ( $this->expire( $key ) ) {
34 return false;
37 return $this->bag[$key][0];
40 function set( $key, $value, $exptime = 0 ) {
41 $this->bag[$key] = array( $value, $this->convertExpiry( $exptime ) );
44 function delete( $key, $time = 0 ) {
45 if ( !isset( $this->bag[$key] ) ) {
46 return false;
49 unset( $this->bag[$key] );
51 return true;
54 function keys() {
55 return array_keys( $this->bag );