RE: [CDBI] has_many caching

"Daniel Williams" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <5B0731A8753509478386ED3D6513B2D1010D0206@isp-per-exch01.win2k.iinet.net.au>
 

It's done multiple times inside of a template toolkit template. There is
definitely ways around it, but this makes the most sense for convenience
and functionality.

 

Daniel

 

  _____  

From: .--- .- -- . ... [mailto:[email protected]] 
Sent: Sunday, 16 April 2006 6:55 AM
To: Daniel Williams
Cc: classdbi-Ra3b/[email protected]
Subject: Re: [CDBI] has_many caching

 

you mean you are making calls to $obj->entries in succession to retrieve
the same set of data?  If so, why don't you just copy the returned array
instead of making a duplicate request?

- james

On 4/13/06, Daniel Williams <[email protected]> wrote:


Hi,

New to the list and relatively new to class::dbi.

I have had a look around and can't seem to find any example of what I'm
trying to achieve.

I have an Event Table, and an Entry Table.

Event is a 1 to many relationship with Entry.

Therefore we use for event:
ChimeFault::Event->has_many(entries => 'ChimeFault::Entry', 'faultid');
And for entry:
ChimeFault::Entry->has_a(faultid => 'ChimeFault::Event'); 


Ok now I retrieve an entry.

my $entry = ChimeFault::Event->retrieve(1);

and then grab all its entries:
my @entries = $entry->entries;
my @secondset = $entry->entries;

The problem is that the Class::DBI executes the SQL to look up the 
entries twice.

I tried caching the returned data in the Event class, but the problem is
that we are using mod_perl. When I do this the garbage script gets all
caught up with the fact that there is event->entry->event->entry 
reference and hence never reaching 0 reference count, which means the
data stays in memory and all sorts of bad things happen.

Any suggestions ?

Daniel



_______________________________________________ 
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi 




-- 
.--- .- -- . ... -.-- --- ---

_______________________________________________
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.