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

Matt S Trout dbix-class at trout.me.uk
Fri Dec 2 22:15:05 GMT 2005


On Fri, Dec 02, 2005 at 04:31:36PM -0500, Brian Gorby wrote:
> I'm trying to understand exactly how the following (simplified) scenario 
> works in a mod_perl web application:
> 
> I've mapped a User table to a User entity class which subclasses 
> Class::DBI::MySQL. In the web application, I define
> 
> $user = User->retrieve();
> 
> And then save $user in a session object, which is also stored in a MySQL 
> table.
> 
> %my_session{my_user} = $user;
> 
> I then restart both Apache and MySQL. The session is restored, and I 
> pull back out $user
> 
> $user = %my_session{my_user};
> 
> I can then make any updates I wish to $user. But why? I thought all I 
> persisted was a reference to some memory that would've gotten destroyed 
> upon restarting of servers.

Apache::Session will use a shared store for the session info; it probably
defaults to a temp file somewhere from which it can reload the info even
after restarting your daemons.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +




More information about the ClassDBI mailing list