1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116:
<?php
namespace qdb;
/**
* A collection of operation that can be executed with a single query.
*
* Operation are executed by a call to {@link \QdbCluster::runBatch()}
* @example
* <code>
* $batch = new QdbBatch();
* $batch->put('key 0', 'value 0');
* $batch->put('key 1', 'value 1');
* $batch->get('key 2');
*
* $result = $cluster->runBatch($batch);
*
* $value2 = $result[2];
* </code>
*/
class QdbBatch
{
/**
* Creates an empty batch, i.e. an empty collection of operation.
*/
function __construct();
/**
* Adds a "compare and swap" operation to the batch.
*
* When executed, the "compare and swap" operation atomically compares a blob with `$comparand` and updates it to `$new_content` if, and only if, they match.
*
* @param string $alias The blob's alias.
* @param string $new_content The new content of the blob in case of match.
* @param string $comparand The content to be compared to.
* @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
* @see QdbBlob::compareAndSwap()
*/
function compareAndSwap($alias, $new_content, $comparand, $expiry_time=0);
/**
* Adds a "get" operation to the batch.
*
* When executed, the "get" operation reads the content of a blob.
*
* @param string $alias The blob's alias.
* @see QdbBlob::get()
*/
function get($alias);
/**
* Adds a "get and remove" operation to the batch.
*
* When executed, the "get and remove" operation atomically reads a blob and removes it.
*
* @param string $alias The blob's alias.
* @see QdbBlob::getAndRemove()
*/
function getAndRemove($alias);
/**
* Adds a "get and remove" operation to the batch.
*
* When executed, the "get and remove" operation atomically reads a blob's content and replaces it.
*
* @param string $alias The blob's alias.
* @param string $content The new content of the blob.
* @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
* @see QdbBlob::getAndUpdate()
*/
function getAndUpdate($alias, $content, $expiry_time=0);
/**
* Adds a "put" operation to the batch.
*
* When executed, the "put" operation creates a blob.
*
* @param string $alias The blob's alias.
* @param string $content The initial content of the blob.
* @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
* @see QdbBlob::put()
*/
function put($alias, $content, $expiry_time=0);
/**
* Adds a "remove" operation to the batch.
* When executed, the "remove" operation removes an entry.
*
* @param string $alias The entry's alias.
* @see QdbEntry::remove()
*/
function remove($alias);
/**
* Adds a "remove if" operation to the batch.
*
* When executed, the "remove if" operation removes a blob if it matches `$comparand`. The operation is atomic.
*
* @param string $alias The blob's alias.
* @param string $comparand The content to be compared to.
* @see QdbBlob::removeIf()
*/
function removeIf($alias, $comparand);
/**
* Adds an "update" operation to the batch.
*
* When executed, the "update" operation sets the content of a blob. It will create the blob if needed.
*
* @param string $alias The blob's alias.
* @param string $content The new content of the blob.
* @param int $expiry_time The absolute expiration time, in seconds since epoch (`0` means "never expires").
* @see QdbBlob::update()
*/
function update($alias, $content, $expiry_time=0);
}
?>