From: Michael G Schwern Date: Sun, 24 Feb 2008 07:43:58 +0000 (-0800) Subject: Add NoObjectIndex which turns the live object index off and removes all the X-Git-Tag: v0.08240~541^2~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f56e59cdad2f0c45ffbfe037d38a878429bb9221;hp=7e36a763a7ba0f4feb35371ddd421d9bc9e62ad1;p=dbsrgits%2FDBIx-Class.git Add NoObjectIndex which turns the live object index off and removes all the hooks in insert and such, but retains stub indexing methods so as not to break code. --- diff --git a/lib/DBIx/Class/CDBICompat/NoObjectIndex.pm b/lib/DBIx/Class/CDBICompat/NoObjectIndex.pm new file mode 100644 index 0000000..d0a68ba --- /dev/null +++ b/lib/DBIx/Class/CDBICompat/NoObjectIndex.pm @@ -0,0 +1,32 @@ +package # hide from PAUSE + DBIx::Class::CDBICompat::NoObjectIndex; + +use strict; +use warnings; + +=head1 NAME + +DBIx::Class::CDBICompat::NoObjectIndex + +=head1 SYNOPSIS + + Part of CDBICompat + +=head1 DESCRIPTION + +Defines empty methods for object indexing. They do nothing. + +Using NoObjectIndex instead of LiveObjectIndex and nocache(1) is a little +faster because it removes code from the object insert and retrieve chains. + +=cut + +sub nocache { return 1 } + +sub purge_dead_from_object_index {} + +sub remove_from_object_index {} + +sub clear_object_index {} + +1; diff --git a/t/cdbi-t/02-Film.t b/t/cdbi-t/02-Film.t index 6a4d7f6..57ad411 100644 --- a/t/cdbi-t/02-Film.t +++ b/t/cdbi-t/02-Film.t @@ -362,9 +362,8 @@ if (0) { } SKIP: { - #skip "DBIx::Class doesn't yet have a live objects index", 3; - #skip "Scalar::Util::weaken not available", 3 - #if !$Class::DBI::Weaken_Is_Available; + skip "Caching has been removed", 5 + if Film->isa("DBIx::Class::CDBICompat::NoObjectIndex"); # my bad taste is your bad taste my $btaste = Film->retrieve('Bad Taste'); diff --git a/t/cdbi-t/object_cache.t b/t/cdbi-t/object_cache.t index e194a31..295bde6 100644 --- a/t/cdbi-t/object_cache.t +++ b/t/cdbi-t/object_cache.t @@ -6,10 +6,10 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } + eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 5); + plan skip_all => 'needs DBD::SQLite for testing' if $@; } INIT { @@ -17,6 +17,12 @@ INIT { use Film; } +plan skip_all => "Object cache is turned off" + if Film->isa("DBIx::Class::CDBICompat::NoObjectIndex"); + +plan tests => 5; + + ok +Film->create({ Title => 'This Is Spinal Tap', Director => 'Rob Reiner',