On Thu, 6 Jul 2000, Nathan Wiger wrote:
> > $session->STORE('visa_number') = '7';
> > print $session->FETCH('visa_number');
> > $session->DELETE('visa_number');
> 
> This isn't really a documented interface - it's an overloading of the
> tie methods so that the tied hash interface works. You can't find this
> by reading the manpage for Apache::Session, only by reading through the
> module itself or knowing enough about tie to know it's there.

I guess I just figured most people knew that was how tie works.  I suppose
it's not an officially supprted interface though.

> > 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.
> 
> Not sure quite what you mean, maybe you can clarify?

Using tie-d methods is slower than using normal methods, so if you have a
method that in turn calls a tie-d method, you're going to have significant
overhead versus just calling the STORE/FETCH methods directly.

> Won't You always need to tie %session to Apache::Session::____ to
> create the initial object, unless I'm missing something?

You can call the TIEHASH method directly to get an object back.

> Are you just referring to using FETCH, STORE, and DELETE directly
> inside the methods (i.e., rather than $session{'param'} use
> $session->FETCH('param') ?)

That would certainly be faster.
 
> > 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.
> 
> Exactly why I'm doing it:
> 
>    $session->visa_number(501);
>    $session->visa_number;
> 
> same function, but it maps to a combination of FETCH and STORE depending
> on the arguments.

I was thinking of a situation where calling the visa_number method also
sets 'validated' to 0 and 'card_type' to 'visa', or something like that.

Anyway, I don't want to discourage you from making an Apache::Session
subclass (it's another rite of passage that many a mod_perler has gone
through), but if all you want is method access to the functionality
already there I'd suggest either calling the TIE methods directly or
modifying Apache::Session to support both interfaces and sending Jeffrey
the patch.  Otherwise you'll definitely be adding some performance
penalties that might limit the usefulness of your additions for people
with busy sites.

- Perrin

Reply via email to