Slide 33
Slide 33 text
REDIS DATA TYPES:
SORTED SETS
Similar to Sets but where every string element is associated to a floating
number value, called score. The elements are always taken sorted by
their score, so unlike Sets it is possible to retrieve a range of elements
zadd(’fruits’, 1, ’apple’);
$client->zadd(’fruits’, 2, ’pie’);
$client->zadd(’fruits’, 2.2, ’pineapple’);
// get fruits sorted set
$client->zrange(‘fruits’, 0, 1, [‘withscores’ => true]);
$client->zrem(’fruits’, ’pineapple’); // removes ‘pineapple’ key
zadd(’fruits’, 0, ’apple’);
$client->zadd(’fruits’, 0, ’pie’);
$client->zadd(’fruits’, 0, ’pineapple’);
// Get all fruits sorted set with scores
$client->zrangebylex(‘fruits’, 0, -1, [‘limit’ => [20, 5]]);
LEXICOGRAPHICAL SORTING