MediaWiki  1.23.12
MapCacheLRU.php
Go to the documentation of this file.
1 <?php
33 class MapCacheLRU {
35  protected $cache = array(); // (key => value)
36 
37  protected $maxCacheKeys; // integer; max entries
38 
43  public function __construct( $maxKeys ) {
44  if ( !is_int( $maxKeys ) || $maxKeys < 1 ) {
45  throw new MWException( __METHOD__ . " must be given an integer and >= 1" );
46  }
47  $this->maxCacheKeys = $maxKeys;
48  }
49 
59  public function set( $key, $value ) {
60  if ( isset( $this->cache[$key] ) ) {
61  $this->ping( $key ); // push to top
62  } elseif ( count( $this->cache ) >= $this->maxCacheKeys ) {
63  reset( $this->cache );
64  $evictKey = key( $this->cache );
65  unset( $this->cache[$evictKey] );
66  }
67  $this->cache[$key] = $value;
68  }
69 
76  public function has( $key ) {
77  return isset( $this->cache[$key] );
78  }
79 
88  public function get( $key ) {
89  if ( isset( $this->cache[$key] ) ) {
90  $this->ping( $key ); // push to top
91  return $this->cache[$key];
92  } else {
93  return null;
94  }
95  }
96 
103  public function clear( $keys = null ) {
104  if ( $keys === null ) {
105  $this->cache = array();
106  } else {
107  foreach ( (array)$keys as $key ) {
108  unset( $this->cache[$key] );
109  }
110  }
111  }
112 
118  protected function ping( $key ) {
119  $item = $this->cache[$key];
120  unset( $this->cache[$key] );
121  $this->cache[$key] = $item;
122  }
123 }
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
MapCacheLRU\ping
ping( $key)
Push an entry to the top of the cache.
Definition: MapCacheLRU.php:117
cache
you have access to all of the normal MediaWiki so you can get a DB use the cache
Definition: maintenance.txt:52
key
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition: design.txt:25
MapCacheLRU\__construct
__construct( $maxKeys)
Definition: MapCacheLRU.php:42
MWException
MediaWiki exception.
Definition: MWException.php:26
MapCacheLRU\$maxCacheKeys
$maxCacheKeys
Definition: MapCacheLRU.php:36
MapCacheLRU
Handles a simple LRU key/value map with a maximum number of entries.
Definition: MapCacheLRU.php:33
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MapCacheLRU\$cache
Array $cache
Definition: MapCacheLRU.php:34
$value
$value
Definition: styleTest.css.php:45
MapCacheLRU\has
has( $key)
Check if a key exists.
Definition: MapCacheLRU.php:75
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$keys
$keys
Definition: testCompression.php:63
MapCacheLRU\clear
clear( $keys=null)
Clear one or several cache entries, or all cache entries.
Definition: MapCacheLRU.php:102