MediaWiki master
ArrayStatsStore.php
Go to the documentation of this file.
1<?php
2
4
8class ArrayStatsStore implements StatsStore {
13 private $data = [];
14
16 public function makeKey( $prefix, $internals, $entity ) {
17 $globality = $entity->isGlobal() ? 'global' : 'local';
18 return implode( ':',
19 [ $globality, ...$prefix, ...$internals, ...$entity->getComponents() ]
20 );
21 }
22
24 public function incr( array $values, $ttl ) {
25 foreach ( $values as $key => $value ) {
26 $this->data[$key] ??= [ 0, $ttl ];
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
38 public function query( array $keys ) {
39 $values = [];
40 foreach ( $keys as $key ) {
41 if ( isset( $this->data[$key] ) ) {
42 $values[$key] = $this->data[$key][0];
43 }
44 }
45 return $values;
46 }
47
51 public function getData() {
52 return $this->data;
53 }
54}
makeKey( $prefix, $internals, $entity)
Construct a string key from its components.string
query(array $keys)
Perform a batch of fetch operations.int[] Integers
incr(array $values, $ttl)
Perform a batch of increment operations.
Narrow interface for WRStatsFactory to a memcached-like key-value store.