good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Class DBI and reference countingby Nomis52 (Friar) |
on Jan 10, 2006 at 22:52 UTC ( [id://522339]=perlquestion: print w/replies, xml ) | Need Help?? |
Nomis52 has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks,
I'm using Class::DBI with two classes, A and B with A having many Bs. The database is set up like so:
mysql> select * from test_a; +-----+ | oid | +-----+ | 1 | +-----+ mysql> select * from test_b; +-----+------+------+ | oid | aoid | flag | +-----+------+------+ | 1 | 1 | 0 | | 2 | 1 | 0 | | 3 | 1 | 1 | +-----+------+------+ 3 rows in set (0.01 sec)Where aoid references and oid in test_a . Below is the code for the two classes Testing2.pm
Testing3.pm Now I need to be able to find the particular B that corrosponds to a particular A where flag is 1. So in class A I have: But in my code, flagged is called many times per execution and I'd really like to be able to cache the results of the search so it's only performed once. I tried the following: The problem is now that the objects a and b no longer get destroyed when the execution finishes because the reference count never hits 0. This is causing problems under mod_perl. Is there a way to ensure the objects get destroyed or alternatively a better way to do this ? Cheers, Simon N
Back to
Seekers of Perl Wisdom
|
|