MediaWiki REL1_40
ArrayStatsStore.php
Go to the documentation of this file.
1<?php
2
4
8class ArrayStatsStore implements StatsStore {
13 private $data = [];
14
15 public function makeKey( $prefix, $internals, $entity ) {
16 $globality = $entity->isGlobal() ? 'global' : 'local';
17 return implode( ':',
18 array_merge( [ $globality ], $prefix, $internals, $entity->getComponents() )
19 );
20 }
21
22 public function incr( array $values, $ttl ) {
23 foreach ( $values as $key => $value ) {
24 if ( !isset( $this->data[$key] ) ) {
25 $this->data[$key] = [ 0, $ttl ];
26 }
27 $this->data[$key][0] += $value;
28 }
29 }
30
31 public function delete( array $keys ) {
32 foreach ( $keys as $key ) {
33 unset( $this->data[$key] );
34 }
35 }
36
37 public function query( array $keys ) {
38 $values = [];
39 foreach ( $keys as $key ) {
40 if ( isset( $this->data[$key] ) ) {
41 $values[$key] = $this->data[$key][0];
42 }
43 }
44 return $values;
45 }
46
50 public function getData() {
51 return $this->data;
52 }
53}
makeKey( $prefix, $internals, $entity)
Construct a string key from its components.
query(array $keys)
Perform a batch of fetch operations.
incr(array $values, $ttl)
Perform a batch of increment operations.
The narrow interface WRStats needs into a memcached-like key-value store.