=item * get_next_key
-=item * setup_fh
+=item * setup
=item * begin_work
=cut
+=head2 read_value( $obj, $key )
+This takes an object that provides _base_offset() and a string. It returns the
+value stored in the corresponding Sector::Value's data section.
+
+=cut
+
+sub read_value { die "read_value must be implemented in a child class" }
+
+=head2 get_classname( $obj )
+
+This takes an object that provides _base_offset() and returns the classname (if
+any) associated with it.
+
+It delegates to Sector::Reference::get_classname() for the heavy lifting.
+
+It performs a staleness check.
+
+=cut
+
+sub get_classname { die "get_classname must be implemented in a child class" }
+
+=head2 make_reference( $obj, $old_key, $new_key )
+
+This takes an object that provides _base_offset() and two strings. The
+strings correspond to the old key and new key, respectively. This operation
+is equivalent to (given C<< $db->{foo} = []; >>) C<< $db->{bar} = $db->{foo} >>.
+
+This returns nothing.
+
+=cut
+
+sub make_reference { die "make_reference must be implemented in a child class" }
+
+=head2 key_exists( $obj, $key )
+
+This takes an object that provides _base_offset() and a string for
+the key to be checked. This returns 1 for true and "" for false.
+
+=cut
+
+sub key_exists { die "key_exists must be implemented in a child class" }
+
+=head2 delete_key( $obj, $key )
+
+This takes an object that provides _base_offset() and a string for
+the key to be deleted. This returns the result of the Sector::Reference
+delete_key() method.
+
+=cut
+
+sub delete_key { die "delete_key must be implemented in a child class" }
+
+=head2 write_value( $obj, $key, $value )
+
+This takes an object that provides _base_offset(), a string for the
+key, and a value. This value can be anything storable within L<DBM::Deep/>.
+
+This returns 1 upon success.
+
+=cut
+
+sub write_value { die "write_value must be implemented in a child class" }
+
+=head2 setup( $obj )
+
+This takes an object that provides _base_offset(). It will do everything needed
+in order to properly initialize all values for necessary functioning. If this is
+called upon an already initialized object, this will also reset the inode.
+
+This returns 1.
+
+=cut
+
+sub setup { die "setup must be implemented in a child class" }
+
+=head2 begin_work( $obj )
+
+This takes an object that provides _base_offset(). It will set up all necessary
+bookkeeping in order to run all work within a transaction.
+
+If $obj is already within a transaction, an error wiill be thrown. If there are
+no more available transactions, an error will be thrown.
+
+This returns undef.
+
+=cut
+
+sub begin_work { die "begin_work must be implemented in a child class" }
+
+=head2 rollback( $obj )
+
+This takes an object that provides _base_offset(). It will revert all
+actions taken within the running transaction.
+
+If $obj is not within a transaction, an error will be thrown.
+
+This returns 1.
+
+=cut
+
+sub rollback { die "rollback must be implemented in a child class" }
+
+=head2 commit( $obj )
+
+This takes an object that provides _base_offset(). It will apply all
+actions taken within the transaction to the HEAD.
+
+If $obj is not within a transaction, an error will be thrown.
+
+This returns 1.
+
+=cut
+
+sub commit { die "commit must be implemented in a child class" }
=head2 get_next_key( $obj, $prev_key )
my $self = shift;
my ($obj, $prev_key) = @_;
- # XXX Need to add logic about resetting the iterator if any key in the reference has changed
+ # XXX Need to add logic about resetting the iterator if any key in the
+ # reference has changed
unless ( $prev_key ) {
$obj->{iterator} = DBM::Deep::Iterator->new({
base_offset => $obj->_base_offset,
return $obj->{iterator}->get_next_key( $obj );
}
+=head2 lock_exclusive()
+
+This takes an object that provides _base_offset(). It will guarantee that
+the storage has taken precautions to be safe for a write.
+
+This returns nothing.
+
+=cut
+
+sub lock_exclusive {
+ my $self = shift;
+ my ($obj) = @_;
+ return $self->storage->lock_exclusive( $obj );
+}
+
+=head2 lock_shared()
+
+This takes an object that provides _base_offset(). It will guarantee that
+the storage has taken precautions to be safe for a read.
+
+This returns nothing.
+
+=cut
+
+sub lock_shared {
+ my $self = shift;
+ my ($obj) = @_;
+ return $self->storage->lock_shared( $obj );
+}
+
+=head2 unlock()
+
+This takes an object that provides _base_offset(). It will guarantee that
+the storage has released the most recently-taken lock.
+
+This returns nothing.
+
+=cut
+
+sub unlock {
+ my $self = shift;
+ my ($obj) = @_;
+
+ my $rv = $self->storage->unlock( $obj );
+
+ $self->flush if $rv;
+
+ return $rv;
+}
+
+=head1 INTERNAL METHODS
+
+The following methods are internal-use-only to DBM::Deep::Engine and its
+child classes.
+
+=cut
+
+=head2 flush()
+
+This takes no arguments. It will do everything necessary to flush all things to
+disk. This is usually called during unlock() and setup().
+
+This returns nothing.
+
+=cut
+
+sub flush {
+ my $self = shift;
+
+ # Why do we need to have the storage flush? Shouldn't autoflush take care of
+ # things? -RobK, 2008-06-26
+ $self->storage->flush;
+
+ return;
+}
+
1;
__END__
return $self;
}
-=head2 read_value( $obj, $key )
-
-This takes an object that provides _base_offset() and a string. It returns the
-value stored in the corresponding Sector::Value's data section.
-
-=cut
-
sub read_value {
my $self = shift;
my ($obj, $key) = @_;
return $value_sector->data;
}
-=head2 get_classname( $obj )
-
-This takes an object that provides _base_offset() and returns the classname (if
-any) associated with it.
-
-It delegates to Sector::Reference::get_classname() for the heavy lifting.
-
-It performs a staleness check.
-
-=cut
-
sub get_classname {
my $self = shift;
my ($obj) = @_;
return $sector->get_classname;
}
-=head2 make_reference( $obj, $old_key, $new_key )
-
-This takes an object that provides _base_offset() and two strings. The
-strings correspond to the old key and new key, respectively. This operation
-is equivalent to (given C<< $db->{foo} = []; >>) C<< $db->{bar} = $db->{foo} >>.
-
-This returns nothing.
-
-=cut
-
sub make_reference {
my $self = shift;
my ($obj, $old_key, $new_key) = @_;
return;
}
-=head2 key_exists( $obj, $key )
-
-This takes an object that provides _base_offset() and a string for
-the key to be checked. This returns 1 for true and "" for false.
-
-=cut
-
sub key_exists {
my $self = shift;
my ($obj, $key) = @_;
return $data ? 1 : '';
}
-=head2 delete_key( $obj, $key )
-
-This takes an object that provides _base_offset() and a string for
-the key to be deleted. This returns the result of the Sector::Reference
-delete_key() method.
-
-=cut
-
sub delete_key {
my $self = shift;
my ($obj, $key) = @_;
});
}
-=head2 write_value( $obj, $key, $value )
-
-This takes an object that provides _base_offset(), a string for the
-key, and a value. This value can be anything storable within L<DBM::Deep/>.
-
-This returns 1 upon success.
-
-=cut
-
sub write_value {
my $self = shift;
my ($obj, $key, $value) = @_;
return 1;
}
-=head2 setup_fh( $obj )
-
-This takes an object that provides _base_offset(). It will do everything needed
-in order to properly initialize all values for necessary functioning. If this is
-called upon an already initialized object, this will also reset the inode.
-
-This returns 1.
-
-=cut
-
-sub setup_fh {
+sub setup {
my $self = shift;
my ($obj) = @_;
return 1;
}
-=head2 begin_work( $obj )
-
-This takes an object that provides _base_offset(). It will set up all necessary
-bookkeeping in order to run all work within a transaction.
-
-If $obj is already within a transaction, an error wiill be thrown. If there are
-no more available transactions, an error will be thrown.
-
-This returns undef.
-
-=cut
-
sub begin_work {
my $self = shift;
my ($obj) = @_;
return;
}
-=head2 rollback( $obj )
-
-This takes an object that provides _base_offset(). It will revert all
-actions taken within the running transaction.
-
-If $obj is not within a transaction, an error will be thrown.
-
-This returns 1.
-
-=cut
-
sub rollback {
my $self = shift;
my ($obj) = @_;
return 1;
}
-=head2 commit( $obj )
-
-This takes an object that provides _base_offset(). It will apply all
-actions taken within the transaction to the HEAD.
-
-If $obj is not within a transaction, an error will be thrown.
-
-This returns 1.
-
-=cut
-
sub commit {
my $self = shift;
my ($obj) = @_;
return 1;
}
-=head2 lock_exclusive()
-
-This takes an object that provides _base_offset(). It will guarantee that
-the storage has taken precautions to be safe for a write.
-
-This returns nothing.
-
-=cut
-
-sub lock_exclusive {
- my $self = shift;
- my ($obj) = @_;
- return $self->storage->lock_exclusive( $obj );
-}
-
-=head2 lock_shared()
-
-This takes an object that provides _base_offset(). It will guarantee that
-the storage has taken precautions to be safe for a read.
-
-This returns nothing.
-
-=cut
-
-sub lock_shared {
- my $self = shift;
- my ($obj) = @_;
- return $self->storage->lock_shared( $obj );
-}
-
-=head2 unlock()
-
-This takes an object that provides _base_offset(). It will guarantee that
-the storage has released all locks taken.
-
-This returns nothing.
-
-=cut
-
-sub unlock {
- my $self = shift;
- my ($obj) = @_;
-
- my $rv = $self->storage->unlock( $obj );
-
- $self->flush if $rv;
-
- return $rv;
-}
-
=head1 INTERNAL METHODS
The following methods are internal-use-only to DBM::Deep::Engine::File.
return $loc;
}
-=head2 flush()
-
-This takes no arguments. It will do everything necessary to flush all things to
-disk. This is usually called during unlock() and setup_fh().
-
-This returns nothing.
-
-=cut
-
-sub flush {
- my $self = shift;
-
- # Why do we need to have the storage flush? Shouldn't autoflush take care of things?
- # -RobK, 2008-06-26
- $self->storage->flush;
-}
-
=head2 ACCESSORS
The following are readonly attributes.