You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ask Bjoern Hansen <as...@valueclick.com> on 2002/05/23 01:23:38 UTC

Apache::DBI connection cache

Apache::DBI is turning the argument hashref into the "cache key" 
with the following code,

	my ($key, $val);
	while (($key,$val) = each %{$args[3]}) {
           $Idx .= "$;$key=$val";
	}

can anyone think of a good reason not to change that to something 
like

  map { $Idx .= "$;$_=$args[3]->{$_}" } sort keys %{$args[3]};

(or a similar for loop)

(My problem, obviously, was that Apache::DBI got several connections
to the same database with the same args; but the hash had the args
ordered in a different way.)


 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/         !try; do();



Re: Apache::DBI connection cache

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Ask Bjoern Hansen wrote:

> Apache::DBI is turning the argument hashref into the "cache key" 
> with the following code,
> 
> 	my ($key, $val);
> 	while (($key,$val) = each %{$args[3]}) {
>            $Idx .= "$;$key=$val";
> 	}
> 
> can anyone think of a good reason not to change that to something 
> like
> 
>   map { $Idx .= "$;$_=$args[3]->{$_}" } sort keys %{$args[3]};
> 
> (or a similar for loop)
> 
> (My problem, obviously, was that Apache::DBI got several connections
> to the same database with the same args; but the hash had the args
> ordered in a different way.)

FWIW, this code was borrowed right from DBI (at least I think it was).

see the very end of Tim's recent (5/1/2002) message here

   http://archive.develooper.com/dbi-users@perl.org/msg11273.html

to see how DBI connect_cached() now handles it (and Tim's suggested 
change to Apache::DBI).

HTH

--Geoff


Re: Apache::DBI connection cache

Posted by Ask Bjoern Hansen <as...@develooper.com>.
On Wed, 22 May 2002, Perrin Harkins wrote:

> > Apache::DBI is turning the argument hashref into the "cache key" 
> > with the following code,
[...]
> > can anyone think of a good reason not to change that to something 
> > like
> > 
> >   map { $Idx .= "$;$_=$args[3]->{$_}" } sort keys %{$args[3]};
> 
> Good find.  That's a bug.  Fix it.

I sent a patch to Edmund.


 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/         !try; do();


Re: Apache::DBI connection cache

Posted by Perrin Harkins <pe...@elem.com>.
Ask Bjoern Hansen wrote:
> Apache::DBI is turning the argument hashref into the "cache key" 
> with the following code,
> 
> 	my ($key, $val);
> 	while (($key,$val) = each %{$args[3]}) {
>            $Idx .= "$;$key=$val";
> 	}
> 
> can anyone think of a good reason not to change that to something 
> like
> 
>   map { $Idx .= "$;$_=$args[3]->{$_}" } sort keys %{$args[3]};

Good find.  That's a bug.  Fix it.

- Perrin