On Wed, Oct 11, 2006 at 06:31:21PM -0500, Brandon Black wrote:
>    On 10/11/06, Tim Bunce <[EMAIL PROTECTED]> wrote:
> 
>      Whenever this topic has come up (which isn't very often) I've suggested
>      that people try tying the hash that CachedKids is a reference to.
> 
>      Here's a slide from 2002 :-)
> 
>               
> [2]http://search.cpan.org/src/TIMB/DBI_AdvancedTalk_2002/sld032.htm
> 
>      Could you try out that approach? (I don't think anyone has yet.)
> 
>      It has the added advantage of not adding any cost for people who don't
>      need it.
> 
>    As it turns out, CPAN has Tie::Cache::LRU, which seems to already 
> perfectly fit the bill, and is
>    subclassable (for instance, Tie::Cache::LRU::Expires works great too, and 
> also supports the "max_age"
>    concept that was in my patch).  The job comes down to a one-liner this way.

Have you actually tested it and confirmed it behaves as you'd like?

>    How about a doc patch something like this, so people don't ask anymore?

Thanks. I'd always hoped it would be that simple in practice.
I'll wait till you confirm it works okay before applying.

> ==================================================================
> --- DBI.pm    (revision 11195)
> +++ DBI.pm    (local)
> @@ -4257,7 +4257,13 @@
>  which will ensure that prepare_cached only returns statements cached
>  by that line of code in that source file. 
>  
> +If you'd like the cache to managed intelligently, you can tie the
> +hashref returned by C<CachedKids> to an appropriate caching module,
> +such as L<Tie::Cache::LRU>:
>  
> +  my $cache = $dbh->{CachedKids};
> +  tie $cache, 'Tie::Cache::LRU', 500;

Shouldn't that be 

        tie %$cache, ...

Tim.

Reply via email to