\WurflCloud_Client_Config
Configuration class for the WurflCloud_Client
A usage example of WurflCloud_Client_Config:
<code>
// Create a configuration object
$config = new WurflCloud_Client_Config();
// Paste your API Key below
$config->api_key = 'xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
</code>
Synopsis
class WurflCloud_Client_Config
{
- // constants
- const API_HTTP = 'http';
- const API_TCP = 'tcp';
- const METHOD_CURL = 'WurflCloud_HttpClient_Curl';
- const METHOD_FSOCK = 'WurflCloud_HttpClient_Fsock';
- // members
- public integer $http_timeout = 1000;
- public boolean $compression = true;
- public string $http_method = self::METHOD_FSOCK;
- public boolean $auto_purge = false;
- public integer $report_interval = 60;
- public string $api_type = 'http';
- public $api_key = NULL;
- public array $wcloud_servers = ;
- private array $current_server = ;
- // methods
- public void addCloudServer()
- public void clearServers()
- public string getCloudHost()
- public array getWeightedServer()
Constants
Name | Value |
---|---|
API_HTTP | 'http' |
API_TCP | 'tcp' |
METHOD_CURL | 'WurflCloud_HttpClient_Curl' |
METHOD_FSOCK | 'WurflCloud_HttpClient_Fsock' |
Members
private
- $current_server
—
array
The WURFL Cloud Server that is currently in use, formatted like: 'server_nickname' => array('url', 'weight')
public
- $api_key
—
string
WURFL Cloud Service API Key - $api_type
—
string
The WURFL Cloud API Type to be used. Currently, only WurflCloud_Client_Config::API_HTTP is supported. - $auto_purge
—
boolean
If true, the entire cache (e.g. memcache, APC) will be cleared if the WURFL Cloud Service has been updated. This option should not be enabled for production use since it will result in a massive cache purge, which will result in higher latency lookups. - $compression
—
boolean
Enables or disables the use of compression in the WURFL Cloud response. Using compression can increase CPU usage in very high traffic environments, but will decrease network traffic and latency. - $http_method
—
string
Force a given HTTP method - $http_timeout
—
int
The timeout in milliseconds to wait for the WURFL Cloud request to complete - $report_interval
—
int
The interval in seconds that after which API will report its performance - $wcloud_servers
—
array
WURFL Cloud servers to use for uncached requests. The "weight" field can contain any positive number, the weights are relative to each other.
Methods
public
- addCloudServer() — Adds the specified WURFL Cloud Server
- clearServers() — Removes the WURFL Cloud Servers
- getCloudHost() — Determines the WURFL Cloud Server that will be used and returns its URL.
- getWeightedServer() — Uses a weighted-random algorithm to chose a server from the pool