/usr/share/perl5/Redis/Hash.pm is in libredis-perl 2:1.9760-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | #
# This file is part of Redis
#
# This software is Copyright (c) 2013 by Pedro Melo, Damien Krotkine.
#
# This is free software, licensed under:
#
# The Artistic License 2.0 (GPL Compatible)
#
package Redis::Hash;
{
$Redis::Hash::VERSION = '1.976';
}
# ABSTRACT: tie Perl hashes to Redis hashes
# VERSION
# AUTHORITY
use strict;
use warnings;
use Tie::Hash;
use base qw/Redis Tie::StdHash/;
sub TIEHASH {
my ($class, $prefix, @rest) = @_;
my $self = $class->new(@rest);
$self->{prefix} = $prefix ? "$prefix:" : '';
return $self;
}
sub STORE {
my ($self, $key, $value) = @_;
$self->set($self->{prefix} . $key, $value);
}
sub FETCH {
my ($self, $key) = @_;
$self->get($self->{prefix} . $key);
}
sub FIRSTKEY {
my $self = shift;
$self->{prefix_keys} = [$self->keys($self->{prefix} . '*')];
$self->NEXTKEY;
}
sub NEXTKEY {
my $self = shift;
my $key = shift @{ $self->{prefix_keys} };
return unless defined $key;
my $p = $self->{prefix};
$key =~ s/^$p// if $p;
return $key;
}
sub EXISTS {
my ($self, $key) = @_;
$self->exists($self->{prefix} . $key);
}
sub DELETE {
my ($self, $key) = @_;
$self->del($self->{prefix} . $key);
}
sub CLEAR {
my ($self) = @_;
$self->del($_) for $self->keys($self->{prefix} . '*');
$self->{prefix_keys} = [];
}
1; ## End of Redis::Hash
__END__
=pod
=encoding UTF-8
=head1 NAME
Redis::Hash - tie Perl hashes to Redis hashes
=head1 VERSION
version 1.976
=head1 DESCRIPTION
Ties a Perl hash to Redis. Note that it doesn't use Redis Hashes, but
implements a fake hash using regular keys like "prefix:KEY".
If no C<prefix> is given, it will tie the entire Redis database as a hash.
Future versions will also allow you to use real Redis hash structures.
=head1 SYNOPSYS
## Create fake hash using keys like 'hash_prefix:KEY'
tie %my_hash, 'Redis::Hash', 'hash_prefix', @Redis_new_parameters;
## Treat the entire Redis database as a hash
tie %my_hash, 'Redis::Hash', undef, @Redis_new_parameters;
$value = $my_hash{$key};
$my_hash{$key} = $value;
@keys = keys %my_hash;
@values = values %my_hash;
%my_hash = reverse %my_hash;
%my_hash = ();
=head1 AUTHORS
=over 4
=item *
Pedro Melo <melo@cpan.org>
=item *
Damien Krotkine <dams@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Pedro Melo, Damien Krotkine.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
=cut
|