[CDBI] Class::DBI and Apache::Session - Why does it work?

Brian Gorby gorbster at gmail.com
Fri Dec 2 23:45:31 GMT 2005


On 12/2/05 5:29 PM, Perrin Harkins wrote:
> No, you persisted the complete state of the object at that time.  It
> gets run through Storable.
> 
> By the way -- don't do this!  You might lose updates made in the
> database between the time you store it and retrieve it.  The best way to
> handle this is to put the ID into the session and do a fresh retrieve()
> call when you want the object.

Thanks for the input. I figured it was probably not a good idea to store 
  the entire object in the Session, but I was just curious as to why it 
"worked".

For others running into similar situations, I found the following (only 
after posting originally, of course) related information on the CDBI Wiki:

Objects stored in a (serialized) session object are typically 
unavailable to CDBI's object index. Upshot: Don't store objects there -- 
only store scalars (object ID's, etc.) "The object index works by 
keeping a hash of weak references to all objects in the current process 
as they are loaded from the database. It does this in the constructor. 
Things you put in the session are never loaded from the database again, 
so they don't get registered in the object index. The session just runs 
the object through a Storable::thaw, without calling the constructor."

(http://wiki.class-dbi.com/wiki/Common_problems)

-Brian





More information about the ClassDBI mailing list