On 02/14/2011 04:25 AM, Ramesh Venkitaswaran wrote:
On Sun, Feb 13, 2011 at 8:23 PM, Damon Courtney<[email protected]> wrote:
I usually would just create a single DIO object in the global namespace if it
didn't already exist. Something like:
if {[info commands ::DIO] eq ""} {
## Create ::DIO object
}
I did that as part of the initialization of my code. Since the created
connection exists in the global namespace, it doesn't get deleted when the
::request namespace is destroyed, so it sticks around between invocations.
Ah, that's a good tip. Could the open connection be source in as a
part the ChildInitScript directive and the close connection would be
in the ChildExitScript directive?
Yes, Child[Init|Exit]Script directive are there for this purpose too.
They run one at global level upon child creation, therefore everything
they create outside ::request is persistent across http requests, though
you don't necessarily have to store persistent data in the global (::)
namespace. Every user defined namespace that stems from :: is preserved,
only ::request (and descendants) is wiped out.
One additional question though. What's the standard Rivet way to
'ping' the database before using the connection? I'm looking for
something similar to the Apache:DBI's ping() method.
This is an interesting question. I leave a definite answer to Damon, but
I don't think DIO provides an interface method for this functionality.
Working with Mysql I solved the problem introducing a hack in a
'BeforeScript'. Probably not the best way to get it done.
-- Massimo
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]