Redis::Client::Hash - Work with Redis hashes
version 0.014
use Redis::Client; my $client = Redis::Client->new; tie my %hash, 'Redis::Client::Hash', key => 'my_hash', client => $client; my @keys = keys %hash; $hash{foo} = 42; print 1 if exists $hash{bar};
This class provides a tied interface for Redis hashes. Redis hashes are mapped to Perl hashes. Like Perl hashes, Redis hashes contain an unordered set of key-value pairs. Any time the tied hash or one of its elements is evaluated, the corresponding item will be fetched from the Redis store. Any time it is modified, the value will be written to the Redis store.
tie
The following Perl builtins will work the way you expect on Redis hashes.
delete
Removes a key from the hash. (Note that this is not the same as setting the value to undef, in which case the key still exists.)
undef
delete $hash{foo};
exists
Check if a key exists in the hash.
print 1 if exists $hash{blargh};
keys
Retrieves a list of all keys in the hash, in no particular order.
my @keys = keys %hash;
values
Retrieves a list of all values in the hash, in no particular order
my @vals = values %hash;
each
Iterate over key/value pairs from the hash.
while( my ( $key, $val ) = each %hash ) { ... }
Moose::Object
Redis::Client::Role::Tied
Mike Friedman <friedo@friedo.com>
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.
To install Redis::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Redis::Client
CPAN shell
perl -MCPAN -e shell install Redis::Client
For more information on module installation, please visit the detailed CPAN module installation guide.