function acquia_search_multi_subs_check_and_cache_environment_detection in Acquia Search Multiple Indexes 7
Keeps an entry in cache that tracks the current environment, to avoid calling the auto-switch code on every single load.
Parameters
$module_name: Either 'apachesolr' or 'searchapisolr'.
Return value
bool Returns TRUE if environment was the same as cached, FALSE if different.
2 calls to acquia_search_multi_subs_check_and_cache_environment_detection()
- acquia_search_multi_subs_apachesolr_init in lib/
Drupal/ Apachesolr/ acquia_search_multi_subs.apachesolr.inc - Initializes this module's Apache Solr Search Integration module support.
- acquia_search_multi_subs_searchapi_init in lib/
Drupal/ SearchApiSolr/ acquia_search_multi_subs.searchapisolr.inc - Initializes this module's Apache Solr Search Integration module support.
File
- ./
acquia_search_multi_subs.common.inc, line 382 - Helper functions used for the integration with either Solr module.
Code
function acquia_search_multi_subs_check_and_cache_environment_detection($acquia_identifier, $ah_site_environment, $ah_site_name, $ah_region, $sites_foldername, $ah_db_name, $module_name) {
// Note, we only accept 'apachesolr' or 'searchapisolr' as arguments.
if ($module_name != 'apachesolr' && $module_name != 'searchapisolr') {
throw new Exception('Invalid argument value.');
}
$cid = 'acquia_search_multi_subs_env_change_' . $module_name;
$env_config = array(
$acquia_identifier,
$ah_site_environment,
$ah_site_name,
$ah_region,
$sites_foldername,
$ah_db_name,
);
$cached_config = cache_get($cid);
if (!empty($cached_config) && $cached_config->expire > REQUEST_TIME && $cached_config->data == $env_config) {
// We have already initialized this site with the current environment.
return TRUE;
}
// Something is different about the environment, so return TRUE and keep track of this environment.
cache_set($cid, $env_config, 'cache', REQUEST_TIME + 300);
return FALSE;
}