1 package DBM::Deep::Hash;
8 eval { local $SIG{'__DIE__'}; tied( %{$_[0]} ) } || $_[0]
13 # Tied hash constructor method, called by Perl's tie() function.
16 my $args = $class->_get_args( @_ );
18 $args->{type} = $class->TYPE_HASH;
20 return $class->_init($args);
24 my $self = shift->_get_self;
25 my $key = ($self->_root->{filter_store_key})
26 ? $self->_root->{filter_store_key}->($_[0])
29 return $self->SUPER::FETCH( $key );
33 my $self = shift->_get_self;
34 my $key = ($self->_root->{filter_store_key})
35 ? $self->_root->{filter_store_key}->($_[0])
39 return $self->SUPER::STORE( $key, $value );
43 my $self = shift->_get_self;
44 my $key = ($self->_root->{filter_store_key})
45 ? $self->_root->{filter_store_key}->($_[0])
48 return $self->SUPER::EXISTS( $key );
52 my $self = shift->_get_self;
53 my $key = ($self->_root->{filter_store_key})
54 ? $self->_root->{filter_store_key}->($_[0])
57 return $self->SUPER::DELETE( $key );
62 # Locate and return first key (in no particular order)
64 my $self = $_[0]->_get_self;
67 # Make sure file is open
69 if (!defined($self->_fh)) { $self->_open(); }
72 # Request shared lock for reading
74 $self->lock( $self->LOCK_SH );
76 my $result = $self->_get_next_key();
80 return ($result && $self->_root->{filter_fetch_key})
81 ? $self->_root->{filter_fetch_key}->($result)
87 # Return next key (in no particular order), given previous one
89 my $self = $_[0]->_get_self;
91 my $prev_key = ($self->_root->{filter_store_key})
92 ? $self->_root->{filter_store_key}->($_[1])
95 my $prev_md5 = $DBM::Deep::DIGEST_FUNC->($prev_key);
98 # Make sure file is open
100 if (!defined($self->_fh)) { $self->_open(); }
103 # Request shared lock for reading
105 $self->lock( $self->LOCK_SH );
107 my $result = $self->_get_next_key( $prev_md5 );
111 return ($result && $self->_root->{filter_fetch_key})
112 ? $self->_root->{filter_fetch_key}->($result)
117 # Public method aliases
119 *first_key = *FIRSTKEY;
120 *next_key = *NEXTKEY;