Data-RecordStore
view release on metacpan or search on metacpan
version 6.06
fix typo in perl version in the META files.
version 6.05
removed some old files that were confusing tests
version 6.04
removed typo from required perl version.
can now call lock on already locked items
version 6.03
Oh no, missed versioning for a while? In any case, this update
removes 'bin/record_store_convert~' from the build.
version 3.23
Space wasn't being reclaimed during transaction handling.
This version fixes that, and also moves the documentation to
underneath the __END__ marker and updates it.
6.06 - fix typo in perl version in the META files.
6.05 - clean up, removing old files that were confusing tests.
6.04 - allow call to lock for already locked things
remove typo from perl version
6.03 - remove 'bin/record_store_convert~' from the build.
5.04 - cleanup and increase code coverage.
5.03 - changed the open_store interface to either take a single
directory or take options, which now include :
MODE - SINGLE || MULTI - determines if flocking should be done
on the index file
RECOD_STORE_PATH - the directory to store this record store.
lib/Data/RecordStore.pm view on Meta::CPAN
my( $old_silo_id, $old_id_in_silo ) = @{$self->[INDEX_SILO]->get_record($del_id)};
$self->[INDEX_SILO]->put_record( $del_id, [0,0,time] );
if( $old_silo_id ) {
$self->_vacate( $old_silo_id, $old_id_in_silo );
}
$self->_unlock;
} #delete_record
# locks the given lock names
# they are locked in order to prevent deadlocks.
sub lock {
my( $self, @locknames ) = @_;
my( %previously_locked ) = ( map { $_ => 1 } @{$self->[LOCKS]} );
if( @{$self->[LOCKS]} && grep { ! $previously_locked{$_} } @locknames ) {
die "Data::RecordStore->lock cannot be called twice in a row without unlocking between";
}
my $fhs = [];
my $failed;
for my $name (sort @locknames) {
next if $previously_locked{$name}++;
my $lockfile = "$self->[DIRECTORY]/user_locks/$name";
my $fh;
if( -e $lockfile ) {
unless( open ( $fh, '+<', $lockfile ) ) {
$failed = 1;
last;
}
flock( $fh, LOCK_EX ); #WRITE LOCK
}
else {
lib/Data/RecordStore.pm view on Meta::CPAN
sub _write_lock {
my $self = shift;
flock( $self->[LOCK_FH], LOCK_EX );
$self->_fix_transactions;
}
sub _fix_transactions {
my $self = shift;
# check the transactions
# if the transaction is in an incomplete state, fix it. Since the store is write locked
# during transactions, the lock has expired if this point has been reached.
# that means the process that made the lock has fallen.
#
# of course, do a little experiment to test this with two processes and flock when
# one exits before unflocking.
#
my $transaction_index_silo = $self->transaction_silo;
my $last_trans = $transaction_index_silo->entry_count;
while( $last_trans ) {
my( $state ) = @{$transaction_index_silo->get_record( $last_trans )};
lib/Data/RecordStore.pm view on Meta::CPAN
It does not reuse the id.
=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
and will die if that happens.
=head2 unlock
Unlocks all names locked by this thread
=head2 use_transaction()
Returns the current transaction. If there is no
current transaction, it creates one and returns it.
=head2 commit_transaction()
Commits the current transaction, if any.
lib/Data/RecordStore/Versioned.pm view on Meta::CPAN
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.
( run in 1.069 second using v1.01-cache-2.11-cpan-49f99fa48dc )