On Thu, 6 Jul 2000, Nathan Wiger wrote:
> I've created an object interface to Apache::Session. It's a simple
> module that I've called Apache::Session::Object (seemed pretty
> intuitive) that presents the following interface:
> 
>    # Create new session using the default File store
>    use Apache::Session::Object;
>    my $session = new Apache::Session::Object;
> 
>    my $id = $session->session_id;     # get session_id
>    $session->{visa_number} = "4441 2001 2039 1100";
>    $session->param('visa_number') = "4441 2001 2039 1100";   # same
> 
> 
>    # Open existing session in the DB_File store
>    use Apache::Session::Object;
>    my $session2 = new Apache::Session::Object
>       ($id, {Store => 'DB_File', Transaction => 1});
> 
>    print $session2->_session_id;      # leading _ ok
>    
>    # yet another way to skin the same cat
>    $session->visa_number("4441 2001 2039 1100");
>    print $session2->visa_number;

Is there a reason you can't use the OO interface that Apache::Session
comes with?

$session->STORE('visa_number') = '7';
print $session->FETCH('visa_number');
$session->DELETE('visa_number');

If your module is using the tied interface to Apache::Session to do its
work, you're getting the worst of both worlds in terms of performance.  
AUTOLOAD methods can be an additional slowdown if you don't cache
AUTOLOADed methods (i.e. if AUTOLOAD has to resolve the methods every
time).

I can see reasons for creating an OO module that subclasses
Apache::Session, but I would do it to add methods that don't map directly
to a single hash key.

- Perrin

Reply via email to