
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.

The following Perl builtins will work the way you expect on Redis hashes.
deleteRemoves 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.)
delete $hash{foo};
existsCheck if a key exists in the hash.
print 1 if exists $hash{blargh};
keysRetrieves a list of all keys in the hash, in no particular order.
my @keys = keys %hash;
valuesRetrieves a list of all values in the hash, in no particular order
my @vals = values %hash;
eachIterate over key/value pairs from the hash.
while( my ( $key, $val ) = each %hash ) { ... }




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.