Rediska

Follow me on twitter…

Lists

Good news, you can work with Redis lists as with native PHP arrays:

<?php

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

// Initialize list
$list = new Rediska_Key_List('list');

// Add two elements to list
$list[] = 'first element';
$list[] = 'second element';

// Get element with index 1
echo $list[1]; #=> 'second element';

// Set element with index 0
$list[0] = 'new first element';

// Get elements count
echo count($list); #=> 2

// Check if element with index 0 is present
echo isset($list[0]); #=> true

// Iterate list
foreach($list as $element) {
    echo $element;
}

?>

See all available methods.

Comments