MediaWiki  REL1_20
HashBagOStuff.php
Go to the documentation of this file.
00001 <?php
00030 class HashBagOStuff extends BagOStuff {
00031         var $bag;
00032 
00033         function __construct() {
00034                 $this->bag = array();
00035         }
00036 
00041         protected function expire( $key ) {
00042                 $et = $this->bag[$key][1];
00043 
00044                 if ( ( $et == 0 ) || ( $et > time() ) ) {
00045                         return false;
00046                 }
00047 
00048                 $this->delete( $key );
00049 
00050                 return true;
00051         }
00052 
00057         function get( $key ) {
00058                 if ( !isset( $this->bag[$key] ) ) {
00059                         return false;
00060                 }
00061 
00062                 if ( $this->expire( $key ) ) {
00063                         return false;
00064                 }
00065 
00066                 return $this->bag[$key][0];
00067         }
00068 
00075         function set( $key, $value, $exptime = 0 ) {
00076                 $this->bag[$key] = array( $value, $this->convertExpiry( $exptime ) );
00077                 return true;
00078         }
00079 
00085         function delete( $key, $time = 0 ) {
00086                 if ( !isset( $this->bag[$key] ) ) {
00087                         return false;
00088                 }
00089 
00090                 unset( $this->bag[$key] );
00091 
00092                 return true;
00093         }
00094 
00098         function keys() {
00099                 return array_keys( $this->bag );
00100         }
00101 }
00102