MediaWiki REL1_39
WRStatsFactory.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\WRStats;
4
15 private $store;
16
18 private $now;
19
23 public function __construct( StatsStore $store ) {
24 $this->store = $store;
25 }
26
53 public function createWriter( $specs, $prefix = 'WRStats' ) {
54 $writer = new WRStatsWriter( $this->store, $specs, $prefix );
55 if ( $this->now !== null ) {
56 $writer->setCurrentTime( $this->now );
57 }
58 return $writer;
59 }
60
71 public function createReader( $specs, $prefix = 'WRStats' ) {
72 $reader = new WRStatsReader( $this->store, $specs, $prefix );
73 if ( $this->now !== null ) {
74 $reader->setCurrentTime( $this->now );
75 }
76 return $reader;
77 }
78
92 public function createRateLimiter(
93 $conditions, $prefix = 'WRStats', $options = []
94 ) {
95 $rateLimiter = new WRStatsRateLimiter(
96 $this->store, $conditions, $prefix, $options );
97 if ( $this->now !== null ) {
98 $rateLimiter->setCurrentTime( $this->now );
99 }
100 return $rateLimiter;
101 }
102
108 public function setCurrentTime( $now ) {
109 $this->now = $now;
110 }
111}
A factory for WRStats 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,...
The narrow interface WRStats needs into a memcached-like key-value store.