Re: Live_Objects behavior depends on garbage collection timing

[prev] [thread] [next] [Date index for 2004/07/13]

From: Siamak Pazirandeh
Subject: Re: Live_Objects behavior depends on garbage collection timing
Date: 02:17 on 13 Jul 2004
Tim,
 Here is a self contained example, with sql dumps, packages, calling script, and output.

################
#calling script:
################
#!/usr/bin/perl
use Music::DBI;
use strict;
use warnings;

do {
    if (my $cd=Music::CD->retrieve(1)) {
        $cd->year;
        1;
    }
    1;
};
print STDERR Music::DBI->dump_object_index();
###########
# packages:
###########
package Music::DBI;
use base 'Class::DBI';
Music::DBI->connection('dbi:mysql:dbname','name','pass');

package Music::Artist;
use base 'Music::DBI';
Music::Artist->table('artist');
Music::Artist->columns(All => qw/artistid name/);

package Music::CD;
use base 'Music::DBI';
Music::CD->table('cd');
Music::CD->columns(All => qw/artistid title year/);
Music::CD->has_a(artistid => 'Music::Artist');

1;
################
# SQL table dump :
################
CREATE TABLE cd (
  title varchar(255) default NULL,
  year int(11) default NULL,
  artistid int(11) NOT NULL default '0',
  PRIMARY KEY  (artistid)
) TYPE=MyISAM;
INSERT INTO cd VALUES ('thriller',1984,1);
CREATE TABLE artist (
  artistid int(11) NOT NULL default '0',
  name varchar(255) default NULL,
  PRIMARY KEY  (artistid)
) TYPE=MyISAM;
INSERT INTO artist VALUES (1,'michael jackson');

################
# script output:
################
[max@localhost Music]# perl -I/usr/tmp dbi_cache_test.pl
$VAR1 = {
          'Music::Artist|artistid=1' => bless( {
                                                 'artistid' => '1'
                                               }, 'Music::Artist' ),
          'Music::CD|artistid=1' => undef
        };

max

(message missing)

Re: Live_Objects behavior depends on garbage collection timing
Siamak Pazirandeh 02:17 on 13 Jul 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52