MediaWiki master
BagOStuffStatsStore.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\WRStats;
4
5use BagOStuff;
6
15 private $cache;
16
20 public function __construct( BagOStuff $cache ) {
21 $this->cache = $cache;
22 }
23
28 public function makeKey( $prefix, $internals, $entity ) {
29 if ( $entity->isGlobal() ) {
30 return $this->cache->makeGlobalKey(
31 ...$prefix, ...$internals, ...$entity->getComponents() );
32 } else {
33 return $this->cache->makeKey(
34 ...$prefix, ...$internals, ...$entity->getComponents() );
35 }
36 }
37
38 public function incr( array $values, $ttl ) {
39 foreach ( $values as $key => $value ) {
40 $this->cache->incrWithInit(
41 $key,
42 $ttl,
43 $value,
44 $value,
45 BagOStuff::WRITE_BACKGROUND
46 );
47 }
48 }
49
50 public function delete( array $keys ) {
51 $this->cache->deleteMulti( $keys, BagOStuff::WRITE_BACKGROUND );
52 }
53
54 public function query( array $keys ) {
55 return $this->cache->getMulti( $keys );
56 }
57}
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:85
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.