##
$self->lock( LOCK_SH );
- my $tag = $self->_engine->find_blist( $self->_base_offset, $md5 );#, { create => 1 } );
- #XXX This needs to autovivify
- if (!$tag) {
- $self->unlock();
- return;
- }
-
- ##
- # Get value from bucket list
- ##
- my $result = $self->_engine->get_bucket_value( $tag, $md5, $orig_key );
+ my $result = $self->_engine->read_value( $self->_base_offset, $key, $orig_key );
$self->unlock();
sub read_value {
my $self = shift;
- my ($offset, $key) = @_;
+ my ($offset, $key, $orig_key) = @_;
my $dig_key = $self->apply_digest( $key );
- my $tag = $self->find_blist( $offset, $dig_key );
- return $self->get_bucket_value( $tag, $dig_key, $key );
+ my $tag = $self->find_blist( $offset, $dig_key ) or return;
+ return $self->get_bucket_value( $tag, $dig_key, $orig_key );
}
sub delete_key {
my $self = shift;
- my ($offset, $key) = @_;
+ my ($offset, $key, $orig_key) = @_;
my $dig_key = $self->apply_digest( $key );
- my $tag = $self->find_blist( $offset, $dig_key );
- return $self->delete_bucket( $tag, $dig_key, $key );
+ my $tag = $self->find_blist( $offset, $dig_key ) or return;
+ my $value = $self->get_bucket_value( $tag, $dig_key, $orig_key );
+ $self->delete_bucket( $tag, $dig_key, $orig_key );
+ return $value;
}
sub key_exists {
my ($offset, $key) = @_;
my $dig_key = $self->apply_digest( $key );
- my $tag = $self->find_blist( $offset, $dig_key );
+ # exists() returns the empty string, not undef
+ my $tag = $self->find_blist( $offset, $dig_key ) or return '';
return $self->bucket_exists( $tag, $dig_key, $key );
}