Rediska

Follow me on twitter…

Pipelining

If you want to quickly execute several commands in one go, use pipeline() method:

<?php

// Initialize Rediska
$rediska = new Rediska();

// Initialize pipeline, add commands and execute
$result = $rediska->pipeline()
                  ->set('a', 1)
                  ->increment('a', 10)
                  ->rename('a', 'b')
                  ->get('a')
                  ->execute();

// Increment several counters for example
$counters = array('counter1', 'counter2', 'counterN');

// Initialize pipeline
$pipeline = $rediska->pipeline();
foreach($counters as $counter) {
    // Add command to pipeline
    $pipeline->increment($counter);
}
// Execute and return responses
$result = $pipeline->execute();

?>

Comments

Fork me on GitHub