You are here

function statsd_instance in StatsD 7.2

Static instance function for StatsD.

Parameters

$parameters: Set of default parameters that can be used to make an unique statsd object

Return value

StatsD Return the same instance on each call, unless drupal_static() is reset.

2 calls to statsd_instance()
statsd_admin_settings in ./statsd.admin.inc
Page callback for StatsD administrative settings.
statsd_call in ./statsd.module
The generic statsd wrapper. Used for convenience.

File

./statsd.module, line 165

Code

function statsd_instance($parameters = array()) {

  // since we could have different sets of parameters across the whole site
  // we want to make sure we have a different static object per set of unique
  // parameters.
  $parameters_md5 = md5(serialize($parameters));
  $static_name = 'statsd_' . $parameters_md5;
  $statsd =& drupal_static($static_name);
  if (!isset($statsd)) {
    $parameter_defaults = StatsD::getDefaultProperties();
    $parameters = array_merge($parameters_defaults, $parameters);
    $statsd = new StatsD($parameters);
  }
  return $statsd;
}