Roger,

Sounds interesting - as a matter of fact, I'm doing it exactly the same
way on realestate.com.au, except I use the last 2 hex digits as the
directory name. Great minds think alike!

I don't know if many people realise this, but mySQL, for those of you
that use it, will soon include a select_cached function, for doing
exactly the same. Of course, a non-RDSM-specific solution would be great 
as well on the Perl side. I'm using Storable to write the query result to
disk as an array of hashes. I've implemented most of DBI's query methods,
including fetchrow, fetchrow_hashref, fetchrow_arrayref, etc, and it works
quite well and is transparent to the programmer. Page generation speed
improved by up to 100% in a lot of cases.  

I'd suggest that you include an (optionally
implementable) cache-cleaning routine, so that it's an 'all in one'
solution, as well as parameters such as 'maximum cache size' and
cache-timeout per store. Let me know if you'd like any help with getting
this completed, as I'd be happy to help. 

regards,

Peter Skipworth


On Thu, 7 Sep
2000, 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.
> 
> 

-- 
.-----------------------------------------------------.
|       Peter Skipworth        Ph: 03 9897 1121       |
|      Senior Programmer      Mob: 0417 013 292       |
|      realestate.com.au   [EMAIL PROTECTED]     |
`-----------------------------------------------------'

Reply via email to