From: Dave Thomas Date: 2002-07-13T11:59:46+09:00 Subject: Re: cache dbi for web app Tom Sawyer writes: > i am using mod_ruby. just to be clear, using the cgi module dosen't > inhibit mod_ruby in any way right? also, what about extensions. my main > script is .rbx, per mod_ruby, but it requires other scripts that are > just .rb. how does that effect it? and finally... it all gets loaded once and then stays there, getting invoked each time it handles a request. > > > db ||= DBI.connect(...) > > how does this work? It probably should have been $db ||= ... The first time the program is run, $db will be nil, so the above statement, which is equivalent to $db = $db || DBI.connect... will assign the value of DBI.connect to $db. The second and subsequent times the script runs, $db will already be set (to the database connection) and so you won't reconnect. Dave