batch ( $queue )

Specifies that the intended request should be queued for a later batch request.

Access

public

Parameters

Parameter

Type

Required

Description

$queue

CFBatchRequest

Optional

The CFBatchRequest instance to use for managing batch requests. If not available, it generates a new instance of CFBatchRequest.

Returns

Type

Description

$this

A reference to the current instance.

Examples

Batch several requests together, and then cache the responses to APC.

Note: This method is inherited by all service-specific classes.

// Instantiate
$sdb = new AmazonSDB();
$sdb->set_cache_config('apc');

// Prepare for parallel requests
$sdb->batch()->list_domains();
$sdb->batch()->list_domains();

// First time pulls live data
$response = $sdb->batch()->cache('1 minute')->send(false);
var_dump($response[0]->isOK());
var_dump($response[1]->isOK());

// Second time pulls from cache
$response = $sdb->batch()->cache('1 minute')->send(false);
var_dump($response[0]->isOK());
var_dump($response[1]->isOK());
Result:
bool(true)
bool(true)
bool(true)
bool(true)

Batch several requests together, and then cache the responses to the file system.

Note: This method is inherited by all service-specific classes.

// Instantiate
$sdb = new AmazonSDB();
$sdb->set_cache_config('./cache');

// Prepare for parallel requests
$sdb->batch()->list_domains();
$sdb->batch()->list_domains();

// First time pulls live data
$response = $sdb->batch()->cache('1 minute')->send(false);
var_dump($response[0]->isOK());
var_dump($response[1]->isOK());

// Second time pulls from cache
$response = $sdb->batch()->cache('1 minute')->send(false);
var_dump($response[0]->isOK());
var_dump($response[1]->isOK());
Result:
bool(true)
bool(true)
bool(true)
bool(true)

Source

Method defined in sdk.class.php | Toggle source view (20 lines) | View on GitHub

public function batch(CFBatchRequest &$queue = null)
{
    if ($queue)
    {
        $this->batch_object = $queue;
    }
    elseif ($this->internal_batch_object)
    {
        $this->batch_object = &$this->internal_batch_object;
    }
    else
    {
        $this->internal_batch_object = new $this->batch_class();
        $this->batch_object = &$this->internal_batch_object;
    }

    $this->use_batch_flow = true;

    return $this;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback