Data-RecordStore

 view release on metacpan or  search on metacpan

lib/Data/RecordStore/Versioned.pm  view on Meta::CPAN

If an id is passed in, this saves the data to the record
for that id, overwriting what was there.
If an id is not passed in, it creates a new record store.

Returns the id of the record written to.

=head2 fetch( id )

Returns the record associated with the ID. If the ID has no
record associated with it, undef is returned.

=head2 active_entry_count

Scans the index and returns a count of how many records
are marked as having active data

=head2 find_broken_ids

This is a report that scans the store for any ids that
do not map to stored entries

=head2 record_count

Scans the silos and returns a count of how many records
are contained in them.

=head2 entry_count

Returns how many record ids exist.

=head2 record_count

Return how many records there actually are.

=head2 delete_record( id )

Removes the entry with the given id from the store, freeing up its space.
It does not reuse the id.

=head2 has_id( id )

  Returns true if an record with this id exists in the record store.

=head2 next_id

This sets up a new empty record and returns the
id for it.

=head2 empty()

This empties out the entire record store completely.
Use only if you mean it.

=head2 lock( @names )

Adds an advisory (flock) lock for each of the unique names given.
This may not be called twice in a row without an unlock in between.

=head2 unlock

Unlocks all names locked by this thread

=head1 HELPER PACKAGE

Data::RecordStore::Transaction

=head1 HELPER DESCRIPTION

A transaction that can collect actions on the record store and then
writes them as a block.

=head1 HELPER SYNOPSIS

my $transaction = $store->create_transaction;

print join(",", $transaction->get_update_time,
                $transaction->get_process_id,
                $transaction->get_state,
                $transaction->get_id );

my $new_id = $transaction->stow( $data );

my $next_id = $store->next_id;

$transaction->stow( "MORE DATA", $next_id );

$transaction->delete_record( $someid );

if( $is_good ) {
   $transaction->commit;
} else {
   $transaction->rollback;
}

#
# Get a list of transactions that are old and probably stale.
#
for my $trans ($store->list_transactions) {

  next if $trans->get_udpate_time > $too_old;

  my $state = $trans->get_state;
  if( $state == Data::RecordStore::Transaction::TRA_IN_COMMIT
    || $state == Data::RecordStore::Transaction::TRA_CLEANUP_COMMIT )
  {
     $trans->commit;
  }
  elsif( $state == Data::RecordStore::Transaction::TRA_IN_ROLLBACK
    || $state == Data::RecordStore::Transaction::TRA_CLEANUP_ROLLBACK )
  {
     $trans->rollback;
  }
  elsif( $state == Data::RecordStore::Transaction::TRA_ACTIVE )
  {
     # commit or rollback, depending on preference
  }
}

=head1 HELPER METHODS

=head2 get_update_time



( run in 0.531 second using v1.01-cache-2.11-cpan-39bf76dae61 )