Roger Espel Llima wrote:
>
> I've written a very small module to cache SELECT results from DBI
> requests. The interface looks like:
>
> use SelectCache;
>
> my $db = whatever::get_a_handle();
> my $st = qq{ select this, that ... };
> my $rows = SelectCache::select($db, $st, 180);
>
> this returns an arrayref of rows (like the selectall_arrayref function),
> and caches the result in a file, which gets reused for 180 seconds
> instead of asking the db again.
>
> The names of the cache files are the md5's of the select statement,
> using the last hex digit as a subdirectory name. There's no file
> cleanup function; you can always do that from cron with find.
>
> This is all very simple, but it's pretty useful in combination with
> mod_perl, to speed up things like showing the "latest 10 posts", on
> frequently accessed webpages.
>
> The question now is: is there any interest in releasing this? I could
> write some minimal docs and give it a 'proper' module name, if there's
> interest.
I'm certainly interested. One question though - in the module do you
blindly use the cache? I ask because in my instance I display the
contents of a shopping cart on every page. And while only a few pages
change the cart contents, the cart listing does need to be current. How
do you handle this situation?
--
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/