MediaWiki master
Wikimedia\Stats\StatsCache Class Reference

Singleton cache for Metric instances. More...

Public Member Functions

 clear ()
 Clears the cache.
 
 get (string $component, string $name, string $expectedClass)
 Get a metric object from cache or null.
 
 getAllMetrics ()
 Get all metrics from cache.
 
 set (string $component, string $name, $metric)
 Add a metric object to the cache.
 

Static Public Member Functions

static cacheKey (string $component, string $name)
 Get the metric formatted name.
 

Public Attributes

const DELIMITER = '.'
 

Detailed Description

Singleton cache for Metric instances.

For reuse and collision avoidance. Serves as the data source for Metric Emitters.

Author
Cole White
Since
1.41

Definition at line 37 of file StatsCache.php.

Member Function Documentation

◆ cacheKey()

static Wikimedia\Stats\StatsCache::cacheKey ( string $component,
string $name )
static

Get the metric formatted name.

Takes the provided name and constructs a more specific name by combining component and name.

Definition at line 96 of file StatsCache.php.

Referenced by Wikimedia\Stats\StatsCache\get().

◆ clear()

Wikimedia\Stats\StatsCache::clear ( )

Clears the cache.

Definition at line 86 of file StatsCache.php.

◆ get()

Wikimedia\Stats\StatsCache::get ( string $component,
string $name,
string $expectedClass )

Get a metric object from cache or null.

Parameters
string$component
string$name
string$expectedClass
Returns
MetricInterface|null
Exceptions
TypeErrorIf cached value is for a different metric type.

Definition at line 53 of file StatsCache.php.

References Wikimedia\Stats\StatsCache\cacheKey().

◆ getAllMetrics()

Wikimedia\Stats\StatsCache::getAllMetrics ( )

Get all metrics from cache.

Returns
MetricInterface[]

Definition at line 79 of file StatsCache.php.

◆ set()

Wikimedia\Stats\StatsCache::set ( string $component,
string $name,
$metric )

Add a metric object to the cache.

Parameters
string$component
string$name
MetricInterface | NullMetric$metric

Definition at line 70 of file StatsCache.php.

Member Data Documentation

◆ DELIMITER

const Wikimedia\Stats\StatsCache::DELIMITER = '.'

Definition at line 39 of file StatsCache.php.


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