MediaWiki master
Wikimedia\WRStats\WRStatsWriter Class Reference

Writers gather a batch of increment operations and then commit them when flush() is called, or when the writer is destroyed. More...

Public Member Functions

 __construct (StatsStore $store, $specs, $prefix)
 
 __destruct ()
 Commit the batch of increment operations.
 
 flush ()
 Commit the batch of increment operations.
 
 incr ( $name, ?EntityKey $entity=null, $value=1)
 Queue an increment operation.
 
 resetAll (?array $entities=null)
 Delete all stored metrics corresponding to the specs supplied to the constructor, resetting the counters to zero.
 
 resetCurrentTime ()
 Reset the stored current time.
 
 setCurrentTime ( $now)
 Set the time to be used as the current time.
 

Detailed Description

Writers gather a batch of increment operations and then commit them when flush() is called, or when the writer is destroyed.

Since
1.39

Definition at line 11 of file WRStatsWriter.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\WRStats\WRStatsWriter::__construct ( StatsStore $store,
$specs,
$prefix )
Access: internal
Use WRStatsFactory::createWriter instead
Parameters
StatsStore$store
array<string,array>$specs
string | string[]$prefix

Definition at line 29 of file WRStatsWriter.php.

◆ __destruct()

Wikimedia\WRStats\WRStatsWriter::__destruct ( )

Commit the batch of increment operations.

Definition at line 116 of file WRStatsWriter.php.

References Wikimedia\WRStats\WRStatsWriter\flush().

Member Function Documentation

◆ flush()

Wikimedia\WRStats\WRStatsWriter::flush ( )

Commit the batch of increment operations.

Definition at line 106 of file WRStatsWriter.php.

Referenced by Wikimedia\WRStats\WRStatsWriter\__destruct().

◆ incr()

Wikimedia\WRStats\WRStatsWriter::incr ( $name,
?EntityKey $entity = null,
$value = 1 )

Queue an increment operation.

Parameters
string$nameThe metric name
EntityKey | null$entityAdditional storage key components
float | int$valueThe value to add

Definition at line 49 of file WRStatsWriter.php.

◆ resetAll()

Wikimedia\WRStats\WRStatsWriter::resetAll ( ?array $entities = null)

Delete all stored metrics corresponding to the specs supplied to the constructor, resetting the counters to zero.

Parameters
EntityKey[] | null$entitiesAn array of additional storage key components. The default is the empty local entity.

Definition at line 127 of file WRStatsWriter.php.

◆ resetCurrentTime()

Wikimedia\WRStats\WRStatsWriter::resetCurrentTime ( )

Reset the stored current time.

In a long-running process this should be called regularly to write new results.

Returns
void

Definition at line 91 of file WRStatsWriter.php.

◆ setCurrentTime()

Wikimedia\WRStats\WRStatsWriter::setCurrentTime ( $now)

Set the time to be used as the current time.

Parameters
float | int$now

Definition at line 81 of file WRStatsWriter.php.


The documentation for this class was generated from the following file: