From: Rob Kinyon Date: Sun, 14 Feb 2010 17:42:01 +0000 (-0500) Subject: Apply some changes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ba14e04118fbfa4f41947ac9273b97ca1cb78e2;p=dbsrgits%2FDBM-Deep.git Apply some changes --- diff --git a/Build.PL b/Build.PL index 3df9405..758f756 100644 --- a/Build.PL +++ b/Build.PL @@ -1,4 +1,4 @@ -use Module::Build; +use Module::Build 0.28; # for prepare_metadata use strict; use warnings FATAL => 'all'; diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index 294f5ab..7640810 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -566,14 +566,14 @@ sub CLEAR { my $self = shift->_get_self; warn "CLEAR($self)\n" if DEBUG; - unless ( $self->_engine->storage->is_writable ) { + my $engine = $self->_engine; + unless ( $engine->storage->is_writable ) { $self->_throw_error( 'Cannot write to a readonly filehandle' ); } $self->lock_exclusive; - # Dispatch to the specific clearing functionality. - $self->_clear; + $engine->clear; $self->unlock; diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index f2346b4..84f1a6c 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -339,6 +339,31 @@ defined sector type. sub load_sector { $_[0]->sector_type->load( @_ ) } +=head2 clear + +=cut + +=head2 clear( $obj ) + +This takes an object that provides _base_offset() and deletes all its +elements, returning nothing. + +=cut + +sub clear { + my $self = shift; + my $obj = shift; + + my $sector = $self->_load_sector( $obj->_base_offset ) + or return; + + return unless $sector->staleness == $obj->_staleness; + + $sector->clear; + + return; +} + =head2 cache / clear_cache This is the cache of loaded Reference sectors.