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
36 public function incr( array $values, $ttl ) {
37 foreach ( $values as $key => $value ) {
38 $this->cache->incrWithInit(
39 $key,
40 $ttl,
41 $value,
42 $value,
43 BagOStuff::WRITE_BACKGROUND
44 );
45 }
46 }
47
48 public function delete( array $keys ) {
49 $this->cache->deleteMulti( $keys, BagOStuff::WRITE_BACKGROUND );
50 }
51
53 public function query( array $keys ) {
54 return $this->cache->getMulti( $keys );
55 }
56}
Abstract class for any ephemeral data store.
Definition BagOStuff.php:73
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.int[] Integers
Narrow interface for WRStatsFactory to a memcached-like key-value store.