> From: Michael Peters [mailto:[EMAIL PROTECTED] > Dan Horne wrote: > >>The question stands though - is there a way to "cache" the query > >>information for all users? Example: the app can be called from > >>3 different domains, and using the domain information, load 3 > >>different sets of information and store them for every request > >>(changes every 15 minutes). Does anything do this? It's built > >>in to some application servers (like ColdFusion - which has lots > >>of faults, but does cache data in memory for all users very well). > > > > > > Well, you could use one of the Cached::* modules and do something like > > (untested): > > > > sub complex_query { > > my $self = shift; > > my @args = @_; > > my $key = 'complex_query:' . join(',' @args); > > > > my $cache = new Cache::FileCache( ); > > my $rs = $cache->get($key); > > return $rs if defined($rs); > > > > my $statement = 'select ....'; > > $rs = $self->dbh->selectall_arrayref($statement, \%attr, @args); > > $cache->set($key, $rs, "10 minutes"); > > return $rs; > > } > > But you'll really need to benchmark stuff like this. Maintaining a > separate > cache, especially in a non-persistant environment can have some heavy > overhead > (especially using a file based cache system). Most databases are very, > very fast > for simple primary key select statements. It all depends on how > complicated the > queries are, how much effort it takes to transform the data and how often > the > data changes. >
Too true. If the app is seriously db-bound, I'd be inclined to investigate caching the generated page or page snippets (if applicable to the app), to avoid running any queries at all unless the cache has expired. Dan --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
