- SEE ALSO
- COPYRIGHT AND LICENSE
Redis::Client::List - Work with Redis lists
use Redis::Client; my $client = Redis::Client->new; tie my @list, 'Redis::Client::List', key => 'my_list', client => $client; @list = ( 1, 2, 3 ); push @list, 4, 5, 6; my $val = $list; # 1 my $val2 = pop @list; # 6
This class provides a
tied interface to Redis lists. Redis lists are mapped to Perl arrays. Like Perl arrays, a Redis list contains an ordered sequence of values. Any time the list or an element from the list is evaluated, its current value will be fetched from the Redis store. Any time the
tied array or an element of the
tied array is changed, its new value will be written to the Redis store.
The following Perl builtins will work the way you expect on Redis lists.
Returns a true value if the size of the Redis list has an index this high.
print 'List has at least 43 elements' if exists $list;
Deletes the item stored at an index, setting its value to
undef. It does NOT shift the rest of the list down.
delete $list; # sets to undef
Adds elements to the end of the list, using the Redis
push @list, 'foo', 'bar', 'baz';
Removes the last element of the list and returns it, using the Redis
my $last = pop @list;
Removes an element from the beginning of the list and shifts the remaining elements down, using the Redis
my $first = shift @list;
Adds elements to the beginning of a list, using the Redis
unshift @list, 'quux', 'narf';
splice operator is not yet supported for Redis lists.
Mike Friedman <email@example.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Mike Friedman.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.