protected function SearchApiAcquiaSearchMultiService::getAcquiaSubscription in Acquia Search Multiple Indexes 8
Same name and namespace in other branches
- 7 lib/Drupal/SearchApiSolr/SearchApiAcquiaSearchMultiService.php \SearchApiAcquiaSearchMultiService::getAcquiaSubscription()
Get subscription info from the acquia_connector module, and cache it for 6 hours.
Parameters
$acquia_identifier:
$acquia_key:
Return value
FALSE, integer (xmlrpc error number), or subscription data @see acquia_agent_get_subscription()
3 calls to SearchApiAcquiaSearchMultiService::getAcquiaSubscription()
- SearchApiAcquiaSearchMultiService::configurationFormSubmit in src/
Plugin/ search_api/ backend/ SearchApiAcquiaSearchMultiService.php - Overrides SearchApiSolrService::configurationFormSubmit().
- SearchApiAcquiaSearchMultiService::configurationFormValidate in src/
Plugin/ search_api/ backend/ SearchApiAcquiaSearchMultiService.php - Overrides SearchApiSolrService::configurationFormValidate().
- SearchApiAcquiaSearchMultiService::setConnectionOptions in src/
Plugin/ search_api/ backend/ SearchApiAcquiaSearchMultiService.php
File
- src/
Plugin/ search_api/ backend/ SearchApiAcquiaSearchMultiService.php, line 243 - Contains SearchApiAcquiaSearchMultiService.
Class
- SearchApiAcquiaSearchMultiService
- Provides automatic environment switching for Acquia Search servers.
Code
protected function getAcquiaSubscription($acquia_identifier, $acquia_key) {
$subscription = FALSE;
$subscription_cache =& drupal_static(__FUNCTION__, array());
// Get subscription and use cache.
$cid = 'asms-subscription-' . $acquia_identifier . ':' . $acquia_key;
if (isset($subscription_cache[$cid])) {
$subscription = $subscription_cache[$cid];
}
else {
$cached = cache_get($cid);
if ($cached && $cached->data && REQUEST_TIME < $cached->expire && is_array($cached->data)) {
$subscription = $cached->data;
$subscription_cache[$cid] = $subscription;
}
}
// Get subscription from Acquia.
if (empty($subscription) || !is_array($subscription)) {
// We do not want to send a heartbeat to the server, we only need
// subscription data.
$subscription = acquia_agent_get_subscription(array(
'no_heartbeat' => 1,
), $acquia_identifier, $acquia_key);
// Don't cache non-subscription data: XML-RPC client error, etc.
if (!$this
->getAcquiaSubscriptionError($subscription, $acquia_identifier)) {
$subscription_cache[$cid] = $subscription;
// Cache this for 6 hours.
cache_set($cid, $subscription, 'cache', REQUEST_TIME + variable_get('acquia_search_multi_subs_subscription_cache_time', 6 * 60 * 60));
}
}
return $subscription;
}