On Tue, 8 Feb 2000, Saar Picker wrote:

> I've been trying cache DBI database handles using IPC::Shareable and
> IPC::Cache(based on ShareLite) without much luck. This is not necessarily
> a mod-perl problem, but I figured someone on this list must have tried
> this already.

Hi Saar -- sorry I haven't replied yet to your earlier mail.  I'm glad you
wrote to this list.

I don't think that either Shareable or Cache will allow for the storing of
handles or sockets, due to the fact that they both rely on the Storable
module for serialization.  The Storable perldoc points out:

       You can't store GLOB, CODE, FORMLINE, etc... If you can
       define semantics for those operations, feel free to
       enhance Storable so that it can deal with them.

I haven't tried this myself, but I think that the DBI handles will loose
their internal references (such as file/socket descriptors) in the
freezing process.

Someone else recently wrote to me with an example of how they were using
IPC::Cache to store the results of a SQL query, but no one I know of is
using it for the database connections themselves.  I imagine you are
trying to create a connection pool, so as to not have to incur the over
head of opening one each request.  Perhaps you would consider just keeping
the connection open for subsequent requests to the same process by keeping
it global in the mod_perl instance?    Check out this pointer:

   http://perl.apache.org/guide/performance.html#Persistent_DB_Connections

Passing it between processes via IPC would be next to impossible, I
believe.

Hope this helps,

-DeWitt

Reply via email to