,ref_type ENUM( 'H', 'A' ) NOT NULL DEFAULT 'H'
,refcount BIGINT UNSIGNED NOT NULL DEFAULT 1
,classname LONGTEXT
-);
+) ENGINE=MyISAM;
CREATE TABLE datas (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
,value LONGTEXT
,FOREIGN KEY (ref_id) REFERENCES refs (id)
ON DELETE CASCADE ON UPDATE CASCADE
- ,UNIQUE INDEX (ref_id, `key` (900) )
-);
+ ,UNIQUE INDEX (ref_id, `key` (700) )
+) ENGINE=MyISAM;
sub load_sector { $_[0]->sector_type->load( @_ ) }
+=head2 cache / clear_cache
+
+This is the cache of loaded Reference sectors.
+
+=cut
+
+sub cache { $_[0]{cache} ||= {} }
+sub clear_cache { %{$_[0]->cache} = () }
+
=head2 ACCESSORS
The following are readonly attributes.
=item * storage
+=item * sector_type
+
=back
=cut
sub chains_loc { $_[0]{chains_loc} }
sub set_chains_loc { $_[0]{chains_loc} = $_[1] }
-sub cache { $_[0]{cache} ||= {} }
-sub clear_cache { %{$_[0]->cache} = () }
-
=head2 _dump_file()
This method takes no arguments. It's used to print out a textual representation
return $rows->[0]{classname};
}
+# Look to hoist this method into a ::Reference trait
sub data {
my $self = shift;
my ($args) = @_;
$args ||= {};
- my $obj = DBM::Deep->new({
- type => $self->type,
- base_offset => $self->offset,
-# staleness => $self->staleness,
- storage => $self->engine->storage,
- engine => $self->engine,
- });
-
- if ( $self->engine->storage->{autobless} ) {
- my $classname = $self->get_classname;
- if ( defined $classname ) {
- bless $obj, $classname;
+ my $obj;
+ unless ( $obj = $self->engine->cache->{ $self->offset } ) {
+ $obj = DBM::Deep->new({
+ type => $self->type,
+ base_offset => $self->offset,
+ storage => $self->engine->storage,
+ engine => $self->engine,
+ });
+
+ if ( $self->engine->storage->{autobless} ) {
+ my $classname = $self->get_classname;
+ if ( defined $classname ) {
+ bless $obj, $classname;
+ }
}
+
+ $self->engine->cache->{$self->offset} = $obj;
}
# We're not exporting, so just return.
my $self = shift;
# We're not ready to be removed yet.
- if ( $self->decrement_refcount > 0 ) {
- return;
- }
+ return if $self->decrement_refcount > 0;
+
+ # Rebless the object into DBM::Deep::Null.
+ eval { %{ $self->engine->cache->{ $self->offset } } = (); };
+ eval { @{ $self->engine->cache->{ $self->offset } } = (); };
+ bless $self->engine->cache->{ $self->offset }, 'DBM::Deep::Null';
+ delete $self->engine->cache->{ $self->offset };
$self->engine->storage->delete_from(
'datas', { ref_id => $self->offset },
$self->{value};
}
-=pod
-sub write_data {
- my $self = shift;
- my ($args) = @_;
-
- $self->engine->storage->write_to(
- datas => $args->{value}{offset},
- ref_id => $self->offset,
- data_type => 'S',
- key => $args->{key},
- value => $args->{value}{value},
- class => $args->{value}{class},
- );
-
- $args->{value}->reload;
-}
-=cut
-
1;
__END__
return $self->engine->load_sector( $class_offset )->data;
}
+# Look to hoist this method into a ::Reference trait
sub data {
my $self = shift;
my ($args) = @_;
my $self = shift;
# We're not ready to be removed yet.
- if ( $self->decrement_refcount > 0 ) {
- return;
- }
+ return if $self->decrement_refcount > 0;
# Rebless the object into DBM::Deep::Null.
eval { %{ $self->engine->cache->{ $self->offset } } = (); };
##
# basic put/get/push
##
-warn "1\n";
$db->[0] = "elem1";
-warn "2\n";
$db->push( "elem2" );
-warn "3\n";
$db->put(2, "elem3");
-warn "4\n";
$db->store(3, "elem4");
-warn "5\n";
$db->unshift("elem0");
-warn "6\n";
is( $db->[0], 'elem0', "Array get for shift works" );
is( $db->[1], 'elem1', "Array get for array set works" );
use_ok( 'DBM::Deep' );
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
use_ok( 'DBM::Deep' );
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
use_ok( 'DBM::Deep' );
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
use_ok( 'DBM::Deep' );
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
# reindexing at 17 keys vs. attempting to hit the second-level reindex which
# can occur as early as 18 keys and as late as 4097 (256*16+1) keys.
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
{
my $dbm_factory = new_dbm(
locking => 1,
my $max_txns = 255;
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
my $dbm_factory = new_dbm(
num_txns => $max_txns,
);
use_ok( 'DBM::Deep' );
+if ( $ENV{NO_TEST_TRANSACTIONS} ) {
+ done_testing;
+ exit;
+}
+
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
done_testing;
__END__
-warn "-2\n";
$db2->begin_work;
-warn "-1\n";
delete $db2->{bar};
-warn "0\n";
$db2->commit;
-warn "1\n";
ok( !exists $db1->{bar}, "After commit, bar is gone" );
-warn "2\n";