You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Bruce W. Hoylman" <bh...@advtech.uswest.com> on 2000/05/25 17:52:15 UTC

"Global" or module data

Ciao!

RE: "Global" or module data

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>
> >From an Embperl page, I am creating a SELECT/OPTION widget that is
> populated with the results of a database query.  The content of this
> database source is relatively static over time, so I would like to only
> have to hit the database once, create a perl structure of the results if
> it does not already exist, and store it away somewhere for subsequent
> use by *all* sessions.
>
> Is this a recommended use of the %mdat hash?

Consider that the values in the %mdat hash are also store (by
Apache::Session) in some backend store, for example a database if you use
DBIStore. The benefit of this is, that %mdat is shared between all the
childs of Apache.

In your case I would use a normal Perl global (if you are running under
mod_perl). This is not shared between Apache childs, so you get a database
query per child, but it's much faster. Either put your global in a separate
namespace (%myvars::selection) or put the name in the %CLEANUP hash, that
will tell Embperl not to undef this hash at the end of the request.

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------