MediaWiki master
BagOStuffStatsStore.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\WRStats;
4
6
15 private $cache;
16
17 public function __construct( BagOStuff $cache ) {
18 $this->cache = $cache;
19 }
20
25 public function makeKey( $prefix, $internals, $entity ) {
26 if ( $entity->isGlobal() ) {
27 return $this->cache->makeGlobalKey(
28 ...$prefix, ...$internals, ...$entity->getComponents() );
29 } else {
30 return $this->cache->makeKey(
31 ...$prefix, ...$internals, ...$entity->getComponents() );
32 }
33 }
34
35 public function incr( array $values, $ttl ) {
36 foreach ( $values as $key => $value ) {
37 $this->cache->incrWithInit(
38 $key,
39 $ttl,
40 $value,
41 $value,
42 BagOStuff::WRITE_BACKGROUND
43 );
44 }
45 }
46
47 public function delete( array $keys ) {
48 $this->cache->deleteMulti( $keys, BagOStuff::WRITE_BACKGROUND );
49 }
50
51 public function query( array $keys ) {
52 return $this->cache->getMulti( $keys );
53 }
54}
Abstract class for any ephemeral data store.
Definition BagOStuff.php:87
An adaptor allowing WRStats to store data in MediaWiki's BagOStuff.
makeKey( $prefix, $internals, $entity)
Construct a string key from its components.string
incr(array $values, $ttl)
Perform a batch of increment operations.
query(array $keys)
Perform a batch of fetch operations.
Narrow interface for WRStatsFactory to a memcached-like key-value store.