class MemcacheStatsEvent in Memcache API and Integration 8.2
Memcache Stats Event
The memcache stats event stores all the attributes generated by the different types of memcache servers. Currently memcache_admin supports memcache and mcrouter.
Hierarchy
- class \Drupal\memcache_admin\Event\MemcacheStatsEvent extends \Symfony\Component\EventDispatcher\Event
Expanded class hierarchy of MemcacheStatsEvent
3 files declare their use of MemcacheStatsEvent
- McrouterStatsSubscriber.php in memcache_admin/
src/ EventSubscriber/ McrouterStatsSubscriber.php - MemcacheServerStatsSubscriber.php in memcache_admin/
src/ EventSubscriber/ MemcacheServerStatsSubscriber.php - MemcacheStatisticsController.php in memcache_admin/
src/ Controller/ MemcacheStatisticsController.php
File
- memcache_admin/
src/ Event/ MemcacheStatsEvent.php, line 15
Namespace
Drupal\memcache_admin\EventView source
class MemcacheStatsEvent extends Event {
/**
* Event used to build the memcache stats array.
*
* When the stats array is created, this event allows modules to inject extra
* data to be contained within the array.
*/
const BUILD_MEMCACHE_STATS = 'memcache_build_memcache_stats';
/**
* Event used to report out the memcache stats array.
*
* When the stats array is created, this event allows modules to inject extra
* data to be contained within the array.
*/
const REPORT_MEMCACHE_STATS = 'memcache_report_memcache_stats';
/**
* The Stats Array for which to create attributes.
*
* @var array
*/
protected $rawStats;
/**
* The Stats Array for which to create attributes.
*
* @var array
*/
protected $formattedStats = [];
/**
* The Stats Array for which to create attributes.
*
* @var array
*/
protected $totals;
/**
* The Stats Array for which to create attributes.
*
* @var array
*/
protected $report;
/**
* The Stats Array for which to create attributes.
*
* @var array
*/
protected $servers;
/**
* Cache Bin To Retrieve
* @var string $bin
*/
protected $bin;
protected $memcache;
/**
* MemcacheStatsEvent constructor.
*
* @param array $raw_stats
* The Stats Data.
* @param string $bin
* The cache bin.
*
*/
public function __construct(DrupalMemcacheInterface $memcache, string $bin = 'default') {
$this->memcache = $memcache;
$this->rawStats = $memcache
->stats($bin, 'default', TRUE);
$this->formattedStats = [];
$this->bin = $bin;
}
/**
* Get the Stats Array being created.
*
* @return array
* The Stats Object.
*/
public function getRawStats() {
return $this->rawStats;
}
/**
* Gets the stats formatted from a MemcacheStatsInterface.
* @param $server_type
*
* @return array|mixed
*/
public function getFormattedStats($server_type) {
if (isset($this->formattedStats[$server_type])) {
return $this->formattedStats[$server_type];
}
return [];
}
/**
* Returns the memcache connection.
*/
public function getMemcache() {
return $this->memcache;
}
/**
* Returns the cache bin from this event.
*/
public function getCacheBin() {
return $this->bin;
}
/**
* Sets the formatted stats array with relevant data.
*
* @param string $format
* @param string $bin
* @param string $server
* @param \Drupal\memcache_admin\Stats\MemcacheStatsInterface $data
*/
public function updateFormattedStats($format, $bin, $server, $data) {
$this->formattedStats[$format][$bin][$server] = $data;
}
/**
* Update the total column when multiple memcache servers exist.
* @param $total
*/
public function updateTotals($total) {
$this->totals = $total;
}
/**
* Return the total values from all memcache servers.
* @return array
*/
public function getTotals() {
return $this->totals;
}
/**
* Add a new server to the servers array.
* @param string $server
*/
public function updateServers($server) {
$this->servers[] = $server;
}
/**
* Retrieve all servers from the servers array.
*
* @return array
*/
public function getServers() {
return $this->servers;
}
/**
* Update the full report from the event.
* @param $report
*/
public function updateReport($report) {
$this->report = $report;
}
/**
* Returns the stats report.
* @return array
*/
public function getReport() {
return $this->report;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MemcacheStatsEvent:: |
protected | property | Cache Bin To Retrieve | |
MemcacheStatsEvent:: |
protected | property | The Stats Array for which to create attributes. | |
MemcacheStatsEvent:: |
protected | property | ||
MemcacheStatsEvent:: |
protected | property | The Stats Array for which to create attributes. | |
MemcacheStatsEvent:: |
protected | property | The Stats Array for which to create attributes. | |
MemcacheStatsEvent:: |
protected | property | The Stats Array for which to create attributes. | |
MemcacheStatsEvent:: |
protected | property | The Stats Array for which to create attributes. | |
MemcacheStatsEvent:: |
constant | Event used to build the memcache stats array. | ||
MemcacheStatsEvent:: |
public | function | Returns the cache bin from this event. | |
MemcacheStatsEvent:: |
public | function | Gets the stats formatted from a MemcacheStatsInterface. | |
MemcacheStatsEvent:: |
public | function | Returns the memcache connection. | |
MemcacheStatsEvent:: |
public | function | Get the Stats Array being created. | |
MemcacheStatsEvent:: |
public | function | Returns the stats report. | |
MemcacheStatsEvent:: |
public | function | Retrieve all servers from the servers array. | |
MemcacheStatsEvent:: |
public | function | Return the total values from all memcache servers. | |
MemcacheStatsEvent:: |
constant | Event used to report out the memcache stats array. | ||
MemcacheStatsEvent:: |
public | function | Sets the formatted stats array with relevant data. | |
MemcacheStatsEvent:: |
public | function | Update the full report from the event. | |
MemcacheStatsEvent:: |
public | function | Add a new server to the servers array. | |
MemcacheStatsEvent:: |
public | function | Update the total column when multiple memcache servers exist. | |
MemcacheStatsEvent:: |
public | function | MemcacheStatsEvent constructor. |