Hi all,
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.
With either module, I get the following error message:
[Tue Feb 8 16:33:34 2000] [error] Uncaught exception from user code:
dbih_getcom handle 'DBI::db=HASH(0x888b458)' is not a DBI handle
(has no magic)
Example code for IPC::Cache
$cache=new IPC::Cache({namespace=>'foo', expires_in=>3600});
$dbh = DBI->connect('DBI:mysql:host=localhost;database=db',
'foo','bar');
$cache->set('db1', $dbh);
print "dbh ping succeeded\n" if ($dbh->ping);
undef($dbh);
$dbh = $cache->get('db1');
print "dbh ping succeeded\n" if ($dbh->ping);
Error happens after second ping.
Example code for IPC::Shareable
tie(%DBH, 'IPC::Shareable', 'DBHC', {create=>1,destroy=>0});
tied(%DBH)->shlock;
$DBH{'foo'} = DBI->connect("DBI:mysql:host=localhost;database=db",
"foo","bar");
tied(%DBH)->shlock;
untie(%DBH);
tie(%DBH, 'IPC::Shareable', 'DBHC', {create=>1,destroy=>0});
print "Ping succeded\n" if ($DBH{'foo'}->ping);
Basically, after fetching the database handle from shared memory, it no
long functions. Is this something that anybody has seen before?
Thanks,
-Saar Picker
mongomusic.com