63 Assert::parameterType(
'integer', $maxKeys,
'$maxKeys' );
64 Assert::parameter( $maxKeys > 0,
'$maxKeys',
'must be above zero' );
79 $mapCache->cache = ( count( $values ) >
$maxKeys )
109 public function set( $key,
$value, $rank = self::RANK_TOP ) {
110 if ( $this->has( $key ) ) {
112 }
elseif ( count( $this->
cache ) >= $this->maxCacheKeys ) {
113 reset( $this->
cache );
116 unset( $this->timestamps[$evictKey] );
119 if ( $rank < 1.0 && $rank > 0 ) {
128 $this->timestamps[$key] = [
141 public function has( $key, $maxAge = 0.0 ) {
143 throw new UnexpectedValueException(
144 __METHOD__ .
': invalid key; must be string or integer.' );
151 return ( $maxAge <= 0 || $this->
getAge( $key ) <= $maxAge );
163 public function get( $key, $maxAge = 0.0 ) {
164 if ( !$this->has( $key, $maxAge ) ) {
170 return $this->
cache[$key];
180 if ( $this->has( $key ) ) {
187 throw new UnexpectedValueException(
188 __METHOD__ .
": invalid field for '$key'; must be string or integer." );
194 throw new UnexpectedValueException(
"The value of '$key' ($type) is not an array." );
207 public function hasField( $key, $field, $maxAge = 0.0 ) {
208 $value = $this->
get( $key );
211 throw new UnexpectedValueException(
212 __METHOD__ .
": invalid field for '$key'; must be string or integer." );
219 return ( $maxAge <= 0 || $this->
getAge( $key, $field ) <= $maxAge );
228 public function getField( $key, $field, $maxAge = 0.0 ) {
229 if ( !$this->
hasField( $key, $field, $maxAge ) ) {
257 $key, callable $callback, $rank = self::RANK_TOP, $maxAge = 0.0
259 if ( $this->has( $key, $maxAge ) ) {
260 $value = $this->
get( $key );
280 $this->timestamps = [];
284 unset( $this->timestamps[$key] );
296 return $this->maxCacheKeys;
308 Assert::parameterType(
'integer', $maxKeys,
'$maxKeys' );
309 Assert::parameter( $maxKeys > 0,
'$maxKeys',
'must be above zero' );
312 while ( count( $this->
cache ) > $this->maxCacheKeys ) {
313 reset( $this->
cache );
316 unset( $this->timestamps[$evictKey] );
325 private function ping( $key ) {
326 $item = $this->
cache[$key];
336 private function getAge( $key, $field =
null ) {
337 if ( $field !==
null ) {
340 $mtime = $this->timestamps[$key][
self::SIMPLE] ?? $this->epoch;
348 'entries' => $this->
cache,
349 'timestamps' => $this->timestamps
356 $this->timestamps =
$data[
'timestamps'] ?? [];
365 return $this->wallClockOverride ?:
microtime(
true );
373 $this->wallClockOverride =&
$time;
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Handles a simple LRU key/value map with a maximum number of entries.
getField( $key, $field, $maxAge=0.0)
getAge( $key, $field=null)
int $maxCacheKeys
Max number of entries.
static newFromArray(array $values, $maxKeys)
hasField( $key, $field, $maxAge=0.0)
ping( $key)
Push an entry to the top of the cache.
float $epoch
Default entry timestamp if not specified.
unserialize( $serialized)
clear( $keys=null)
Clear one or several cache entries, or all cache entries.
setMaxSize( $maxKeys)
Resize the maximum number of cache entries, removing older entries as needed.
getMaxSize()
Get the maximum number of keys allowed.
setField( $key, $field, $value, $initRank=self::RANK_TOP)
has( $key, $maxAge=0.0)
Check if a key exists.
array $timestamps
Map of (key => (UNIX timestamp, (field => UNIX timestamp)))
float null $wallClockOverride
getWithSetCallback( $key, callable $callback, $rank=self::RANK_TOP, $maxAge=0.0)
Get an item with the given key, producing and setting it if not found.
see documentation in includes Linker php for Linker::makeImageLink & $time
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Generic interface for lightweight expiring object stores.
you have access to all of the normal MediaWiki so you can get a DB use the cache
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
foreach( $res as $row) $serialized