On 7/10/05, Joseph C. Bautista <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
>    I have a menu in hierarchical forms that have a 28K parent/child
> nodes. And I don't like to query it again and again everytime the
> user(s) clicked a certain item to view the information and see the
> children nodes. I was wondering if theres a way for me to cache this
> array so that the script will no longer fetch the data in the database.
> Is there a cache for an array? Or is it possible to get the ref value of
> the array, put it in a cookie and access it again?
> 
>    Any ideas/approach, of course aside from the one mentioned below, are
> appreciated.

The least resource-intensive way to do a Most Recently Used cache that I
know of is to maintain two caches, and check both of them before accessing
your expensive long term storage.  in mod_perl, your process may run long enough
that you will succeed in caching.  There also may be a limit on calls
per process
so that modperl will simply free them itself, so you could just cache the result
to an in-memory structure.

With plain CGI, there's no communication between different invocations of the
page, so on-disk is the way to do.

I published a module to do the old/new simple cache expiration trick
and hide it behind a tie interface, the docs are at
http://search.cpan.org/~davidnico/Tie-Hash-Cache-MRU-0.02/lib/Tie/Hash/Cache/MRU.pm

enjoy!

-- 
David L Nicol
Aesop's fables, with text-sensitive advertising:
http://cronos.advenge.com/pc/aesop/start.html

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to