Martin,
See its source, it's 66 lines altogether (excluding the POD documentation).
Implements FETCH, STORE, EXISTS, DELETE, CLEAR and hash traversal
(each/keys/values).
> The problem is, when I add value to key i.e my $value = $my_hash{key} it
> works but problem occur when I try to delete this value i.e delete
> $my_hash{key} unfortunately still returns assigned value ;/
> What is wrong or how to deal with this ?
The perl's delete() is supposed to return the old value before deletion.
The Redis::Hash doesn't obey this, but returns a status of a redis delete
operation. Other than that, it does its job, it seems:
use Redis::Hash;
my %h; tie %h, 'Redis::Hash';
$h{"foo"} = "hello";
printf("1: %s\n", defined $_ ? $_ : 'UNDEF') for $h{"foo"};
my($ddd) = delete $h{"foo"};
printf("2: %s\n", defined $_ ? $_ : 'UNDEF') for $h{"foo"};
printf("3: %s\n", $ddd);
1: hello
2: UNDEF
3: 1
Btw, don't use hash traversal as implemented by Redis::Hash
unless your database is really small: it uses the redis KEYS call
and collects all matching keys in memory.
Damien Krotkine wrote:
> Why don't you just use Redis, the Perl module ?
>
https://metacpan.org/module/Redis
The Redis::Hash is just a thin wrapper around the Perl module Redis,
by the same author.
> It is of very good quality and performance.
Its performance on pipelined commands is lamentable: it does one packet
roundtrip for each command in a pipeline, instead of sending them all
in one go and receiving an entire reply. There are two bug reports
complaining about this, but it seems the module is unmaintained since
beginning of this year. We ended up rewriting the client-side of the redis
protocol in Perl for SpamAssassin and for amavisd-new projects (TinyRedis),
giving up hope on the CPAN module Redis which we used initially.
It also doesn't support IPv6 (available since redis 2.8.0).
Mark