Skip to Content

Constants

Constants

g6Common.php provides the following constants:

Constant Value
OPTION_URI 'uri'
OPTION_API_MODE 'api_mode'
API_MODE_PASSIVE 'passive'
API_MODE_ACTIVE 'active'
REPLICATION_MIRRORED 'mirrored'
REPLICATION_INITIALIZING 'initializing'
REPLICATION_SUSPENDED 'suspended'
REPLICATION_NONE NULL

OPTION_URI

OPTION_URI is used to supply the connection credentials to the class for connection to the Gear6 Web Cache Appliance.

Used with setOption() and getOption() and the g6Memcache class.
Example: The below example will set the uri and try to authenticate against the Appliance.
  /* Example code */

  /*
    $g6 is a g6Appliance object
    $service is a g6Memcache object
  */

  $g6->setOption(OPTION_URI, 'http://admin:pass@webcache01');
  if ($g6->authenticate() == FALSE) {
      echo("Error connecting to Gear6 Appliancen");
      exit(1);
  }

OPTION_API_MODE

OPTION_API_MODE is used to set or get the mode of the API.

Used with setOption() and getOption() and the g6Memcache class.
Example: The below example tests which mode the API is in and prints out a message related to the mode it is in.
  /* Example code */

  /*
    $g6 is a g6Appliance object
  */

  $result = $g6->getOption(OPTION_API_MODE);
  if ($result == API_MODE_PASSIVE) {
      echo ("API in passive mode.n");
  }
  if ($result == API_MODE_ACTIVE) {
      echo ("API in active mode.n");
  }

API_MODE_PASSIVE

API_MODE_PASSIVE is provided as a possible value for OPTION_API_MODE. Use this setting to put the PHP language bindings into passive mode.

In passive mode all queries are done when refresh() is called. On the first access of the class, refresh() is called automatically. Since data can become stale, the refresh() function is provided to update the internal variables. In passive mode all changes are done when submit() is called. Until submit() is called, all changes are queued up.

Used with setOption() and the g6Appliance class.
Example: The below example puts the API into passive mode.
  /* Example code */

  /*
    $g6 is a g6Appliance object
  */

  $g6->setOption(OPTION_API_MODE, API_MODE_PASSIVE);

API_MODE_ACTIVE

API_MODE_ACTIVE is provided as a possible value for OPTION_API_MODE. Use this setting to put the PHP language bindings into active mode.

In active mode all changes and queries are done immediately and there is no need to call refresh() or submit() while in this mode.

Used with setOption() and the g6Appliance class.
Example: The below example puts the API into active mode.
   /* Example code */

  /*
    $g6 is a g6Appliance object
  */

  $g6->setOption(OPTION_API_MODE, API_MODE_ACTIVE);

REPLICATION_MIRRORED

REPLICATION_MIRRORED is provided as a possible return value from getMirrorState(). Example: The below example gets the mirror state of a memcache service.
   /* Example code */

  /*
    $service is a g6Memcache object
  */

  if ($service->getMirrorState() == REPLICATION_MIRRORED) {
    echo ("Mirror status: Mirrored!n");
  }

REPLICATION_INITIALIZING

REPLICATION_INITIALIZING is provided as a possible return value from getMirrorState().
Used with getMirrorState() and the g6Memcache class.
Example: The below example gets the mirror state of a memcache service.
   /* Example code */

  /*
    $service is a g6Memcache object
  */

  if ($service->getMirrorState() == REPLICATION_INITIALIZING) {
    echo ("Mirror status: Initializing!n");
  }

REPLICATION_SUSPENDED

REPLICATION_SUSPENDED is provided as a possible return value from getMirrorState().
Used with getMirrorState() and the g6Memcache class.
Example: The below example gets the mirror state of a memcache service.
   /* Example code */

  /*
    $service is a g6Memcache object
  */

  if ($service->getMirrorState() == REPLICATION_SUSPENDED) {
    echo ("Mirror status: Suspended!n");
  }

REPLICATION_NONE

REPLICATION_NONE is provided as a possible return value from getMirrorState(). Example: The below example gets the mirror state of a memcache service.
   /* Example code */

  /*
    $service is a g6Memcache object
  */

  if ($service->getMirrorState() == REPLICATION_NONE) {
    echo ("Mirror status: N/An");
  }