Class QdbBatch
A collection of operation that can be executed with a single query.
Operation are executed by a call to \QdbCluster::runBatch()
Namespace: qdb
Example:
$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];
Methods summary
public
|
#
__construct( )
Creates an empty batch, i.e. an empty collection of operation.
Creates an empty batch, i.e. an empty collection of operation.
|
public
|
#
compareAndSwap( string $alias, string $new_content, string $comparand, integer $expiry_time = 0 )
Adds a "compare and swap" operation to the batch.
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.
Parameters
- $alias
- The blob's alias.
- $new_content
- The new content of the blob in case of match.
- $comparand
- The content to be compared to.
- $expiry_time
- The absolute expiration time, in seconds since epoch (
0 means "never expires").
See
|
public
|
#
get( string $alias )
Adds a "get" operation to the batch.
Adds a "get" operation to the batch.
When executed, the "get" operation reads the content of a blob.
Parameters
See
|
public
|
#
getAndRemove( string $alias )
Adds a "get and remove" operation to the batch.
Adds a "get and remove" operation to the batch.
When executed, the "get and remove" operation atomically reads a blob and removes it.
Parameters
See
|
public
|
#
getAndUpdate( string $alias, string $content, integer $expiry_time = 0 )
Adds a "get and remove" operation to the batch.
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.
Parameters
- $alias
- The blob's alias.
- $content
- The new content of the blob.
- $expiry_time
- The absolute expiration time, in seconds since epoch (
0 means "never expires").
See
|
public
|
#
put( string $alias, string $content, integer $expiry_time = 0 )
Adds a "put" operation to the batch.
Adds a "put" operation to the batch.
When executed, the "put" operation creates a blob.
Parameters
- $alias
- The blob's alias.
- $content
- The initial content of the blob.
- $expiry_time
- The absolute expiration time, in seconds since epoch (
0 means "never expires").
See
|
public
|
#
remove( string $alias )
Adds a "remove" operation to the batch.
When executed, the "remove" operation removes an entry.
Adds a "remove" operation to the batch.
When executed, the "remove" operation removes an entry.
Parameters
- $alias
- The entry's alias.
See
|
public
|
#
removeIf( string $alias, string $comparand )
Adds a "remove if" operation to the batch.
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.
Parameters
- $alias
- The blob's alias.
- $comparand
- The content to be compared to.
See
|
public
|
#
update( string $alias, string $content, integer $expiry_time = 0 )
Adds an "update" operation to the batch.
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.
Parameters
- $alias
- The blob's alias.
- $content
- The new content of the blob.
- $expiry_time
- The absolute expiration time, in seconds since epoch (
0 means "never expires").
See
|