MediaWiki master
WRStatsFactory.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\WRStats;
4
15 private $store;
16
18 private $now;
19
20 public function __construct( StatsStore $store ) {
21 $this->store = $store;
22 }
23
50 public function createWriter( $specs, $prefix = 'WRStats' ) {
51 $writer = new WRStatsWriter( $this->store, $specs, $prefix );
52 if ( $this->now !== null ) {
53 $writer->setCurrentTime( $this->now );
54 }
55 return $writer;
56 }
57
68 public function createReader( $specs, $prefix = 'WRStats' ) {
69 $reader = new WRStatsReader( $this->store, $specs, $prefix );
70 if ( $this->now !== null ) {
71 $reader->setCurrentTime( $this->now );
72 }
73 return $reader;
74 }
75
89 public function createRateLimiter(
90 $conditions, $prefix = 'WRStats', $options = []
91 ) {
92 $rateLimiter = new WRStatsRateLimiter(
93 $this->store, $conditions, $prefix, $options );
94 if ( $this->now !== null ) {
95 $rateLimiter->setCurrentTime( $this->now );
96 }
97 return $rateLimiter;
98 }
99
105 public function setCurrentTime( $now ) {
106 $this->now = $now;
107 }
108}
The main entry point to WRStats, for creating readers and writers.
createWriter( $specs, $prefix='WRStats')
Create a writer.
createReader( $specs, $prefix='WRStats')
Create a reader.
createRateLimiter( $conditions, $prefix='WRStats', $options=[])
Create a rate limiter.
setCurrentTime( $now)
Set a current timestamp to be injected into new instances on creation.
A rate limiter with a WRStats backend.
Readers gather a batch of read operations, returning promises.
Writers gather a batch of increment operations and then commit them when flush() is called,...
Narrow interface for WRStatsFactory to a memcached-like key-value store.