use DBICTest;
use Storable qw(dclone freeze nfreeze thaw);
use Scalar::Util qw/refaddr/;
+use Carp;
sub ref_ne {
- my ($refa, $refb) = map { refaddr $_ or die "$_ is not a reference!" } @_[0,1];
+ my ($refa, $refb) = map { refaddr $_ or croak "$_ is not a reference!" } @_[0,1];
cmp_ok (
$refa,
'!=',
my $key = 'tmp_dbic_84serialize_memcached_test';
$stores{memcached} = sub {
- $memcached->set( $key, $_[0], 60 );
+ $memcached->set( $key, $_[0], 60 )
+ or die "Unable to insert into $ENV{DBICTEST_MEMCACHED} - is server running?";
local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema;
return $memcached->get($key);
};
# Test resultsource with cached rows
- my $query_count;
- $cd_rs = $cd_rs->search ({}, { cache => 1 });
+ $schema->is_executed_querycount( sub {
+ $cd_rs = $cd_rs->search ({}, { cache => 1 });
- my $orig_debug = $schema->storage->debug;
- $schema->storage->debug(1);
- $schema->storage->debugcb(sub { $query_count++ } );
+ # this will hit the database once and prime the cache
+ my @cds = $cd_rs->all;
- # this will hit the database once and prime the cache
- my @cds = $cd_rs->all;
-
- lives_ok {
$copy = $store->($cd_rs);
ref_ne($copy, $cd_rs, 'Cached resultset cloned');
is_deeply (
);
is ($copy->count, $cd_rs->count, 'Cached count identical');
- } "serialize cached resultset lives: $name";
-
- is ($query_count, 1, 'Only one db query fired');
-
- $schema->storage->debug($orig_debug);
- $schema->storage->debugcb(undef);
+ }, 1, 'Only one db query fired');
}
# test schema-less detached thaw