NAME

Redis::Client::Hash - Work with Redis hashes

VERSION

version 0.015

SYNOPSIS

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};

DESCRIPTION

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.

INTERFACE

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.)

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 ) { ... }

SEE ALSO

Redis::Client

EXTENDS

CONSUMES

AUTHOR

Mike Friedman <friedo@friedo.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.