Re: Hash Cache using Require

[prev] [thread] [next] [Date index for 2004/12/03]

From: Perrin Harkins
Subject: Re: Hash Cache using Require
Date: 19:39 on 03 Dec 2004
On Fri, 2004-12-03 at 11:17 -0800, Bill Whillers wrote:
> Am I more or less efficient than just creating the hashes directly from 
> hitting the database everytime the application needs it? The database is 
> *not* under heavy load, at all.

If the data is small enough, loading it into memory should work fine,
and will be faster than loading from the database.  If you only need
access to specific items at any given time, I'd read those individually
from the database or use a local dbm file (try MLDBM::Sync or
BerkeleyDB) because it will save you memory over loading the full hash
in each process.

> I've considered writing the cache file as a require-able file knowing that it 
> won't be reloaded unless updated; would this be more reasonable or more 
> pointless?

That would work, but you would have to use something like Apache::Reload
to make it refresh when the file changes.  This is not an issue with the
dbm approach.

- Perrin


        -- 
        Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Hash Cache using Require
Bill Whillers 19:17 on 03 Dec 2004

Re: Hash Cache using Require
Perrin Harkins 19:39 on 03 Dec 2004

Re: Hash Cache using Require
Tom Schindl 12:51 on 04 Dec 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52