protected function DrupalApacheSolrService::setStats in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::setStats()
- 7 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::setStats()
Sets $this->stats with the information about the Solr Core form
1 call to DrupalApacheSolrService::setStats()
- DrupalApacheSolrService::getStats in ./
Drupal_Apache_Solr_Service.php - Get information about the Solr Core.
File
- ./
Drupal_Apache_Solr_Service.php, line 262
Class
- DrupalApacheSolrService
- Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
Code
protected function setStats() {
$data = $this
->getLuke();
$solr_version = $this
->getSolrVersion();
// Only try to get stats if we have connected to the index.
if (empty($this->stats) && isset($data->index->numDocs)) {
if ($solr_version >= 4) {
$url = $this
->_constructUrl(self::STATS_SERVLET_4);
}
else {
$url = $this
->_constructUrl(self::STATS_SERVLET);
}
if ($this->env_id) {
$this->stats_cid = $this->env_id . ":stats:" . $this
->drupal_apachesolr_hash_base64($url);
$cache = cache_get($this->stats_cid, 'cache_apachesolr');
if (isset($cache->data)) {
$this->stats = simplexml_load_string($cache->data);
}
}
// Second pass to populate the cache if necessary.
if (empty($this->stats)) {
$response = $this
->_sendRawGet($url);
$this->stats = simplexml_load_string($response->data);
if ($this->env_id) {
cache_set($this->stats_cid, $response->data, 'cache_apachesolr');
}
}
}
}