send ( $clear_after_send )

Executes the batch request queue by sending all queued requests.

Access

public

Parameters

Parameter

Type

Required

Description

$clear_after_send

boolean

Optional

Whether or not to clear the batch queue after sending a request. Defaults to true. Set this to false if you are caching batch responses and want to retrieve results later.

Returns

Type

Description

array

An array of CFResponse objects.

Source

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

public function send($clear_after_send = true)
{
    if ($this->use_batch_flow)
    {
        // When we send the request, disable batch flow.
        $this->use_batch_flow = false;

        // If we're not caching, simply send the request.
        if (!$this->use_cache_flow)
        {
            $response = $this->batch_object->send();
            $parsed_data = array_map(array($this, 'parse_callback'), $response);
            $parsed_data = new CFArray($parsed_data);

            // Clear the queue
            if ($clear_after_send)
            {
                $this->batch_object->queue = array();
            }

            return $parsed_data;
        }

        // Generate an identifier specific to this particular set of arguments.
        $cache_id = $this->key . '_' . get_class($this) . '_' . sha1(serialize($this->batch_object));

        // Instantiate the appropriate caching object.
        $this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);

        if ($this->delete_cache)
        {
            $this->use_cache_flow = false;
            $this->delete_cache = false;
            return $this->cache_object->delete();
        }

        // Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
        $data_set = $this->cache_object->response_manager(array($this, 'cache_callback_batch'), array($this->batch_object));
        $parsed_data = array_map(array($this, 'parse_callback'), $data_set);
        $parsed_data = new CFArray($parsed_data);

        // Clear the queue
        if ($clear_after_send)
        {
            $this->batch_object->queue = array();
        }

        // End!
        return $parsed_data;
    }

    // Load the class
    $null = new CFBatchRequest();
    unset($null);

    throw new CFBatchRequest_Exception('You must use $object->batch()->send()');
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback