MediaWiki  1.23.12
HashBagOStuff.php
Go to the documentation of this file.
1 <?php
30 class HashBagOStuff extends BagOStuff {
31  var $bag;
32 
33  function __construct() {
34  $this->bag = array();
35  }
36 
41  protected function expire( $key ) {
42  $et = $this->bag[$key][1];
43 
44  if ( ( $et == 0 ) || ( $et > time() ) ) {
45  return false;
46  }
47 
48  $this->delete( $key );
49 
50  return true;
51  }
52 
58  function get( $key, &$casToken = null ) {
59  if ( !isset( $this->bag[$key] ) ) {
60  return false;
61  }
62 
63  if ( $this->expire( $key ) ) {
64  return false;
65  }
66 
67  $casToken = serialize( $this->bag[$key][0] );
68 
69  return $this->bag[$key][0];
70  }
71 
78  function set( $key, $value, $exptime = 0 ) {
79  $this->bag[$key] = array( $value, $this->convertExpiry( $exptime ) );
80  return true;
81  }
82 
90  function cas( $casToken, $key, $value, $exptime = 0 ) {
91  if ( serialize( $this->get( $key ) ) === $casToken ) {
92  return $this->set( $key, $value, $exptime );
93  }
94 
95  return false;
96  }
97 
103  function delete( $key, $time = 0 ) {
104  if ( !isset( $this->bag[$key] ) ) {
105  return false;
106  }
107 
108  unset( $this->bag[$key] );
109 
110  return true;
111  }
112 }
HashBagOStuff\expire
expire( $key)
Definition: HashBagOStuff.php:41
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
HashBagOStuff
This is a test of the interface, mainly.
Definition: HashBagOStuff.php:30
BagOStuff\convertExpiry
convertExpiry( $exptime)
Convert an optionally relative time to an absolute time.
Definition: BagOStuff.php:351
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
BagOStuff
interface is intended to be more or less compatible with the PHP memcached client.
Definition: BagOStuff.php:43
HashBagOStuff\$bag
$bag
Definition: HashBagOStuff.php:31
HashBagOStuff\__construct
__construct()
Definition: HashBagOStuff.php:33
HashBagOStuff\cas
cas( $casToken, $key, $value, $exptime=0)
Definition: HashBagOStuff.php:90
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$value
$value
Definition: styleTest.css.php:45