[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] RFC: CGI::Application::RunModeCache


Quoting Brian Cassidy <suppressed>:

> Hi All,
> 
> Something I've been wanting for a while now is a generic caching system to
> plug in to CGI::Application. For example, I have a CGI::App which uses
> Gedcom.pm. Some of its operations can be quite lengthy, thus caching would
> be wise.
> 
> The following is what I might consider a workable first step.

Great concept!  I really like it.

I do have a couple of concerns/comments though:

- you use exit() to short circuit the execution of the program.  In a CGI
environment that will probably be OK, but in persistant environments that may
cause problems.  I'm pretty sure that mod_perl overrides CORE::exit so that the
program doesn't end, but I'm not so sure about FastCGI and SpeedyCGI.  TO get
around it would probably require a change to CGI::Application though.

- you have effectively hijacked the prerun and postrun methods which means they
are unavailable to any sub/super classes.  This brings me back to my request
from many months ago for the ability to register prerun and postrun hooks so
that you can have multiple prerun/postrun execution points (patch available
here:
http://cees.crtconsulting.ca/perl/patches/CGI-Application-3.21.callbacks.patch)
.  As an interim solution you may want to include a comment in your docs that
lets people know they need to add $self->SUPER::cgiapp_postrun to their own
custom cgiapp_postrun method if they use it (same for cgiapp_prerun).  Otherwise
your cache code stops working.

- Is there a specific reason you are using Data::Dumper to flatten the object? 
I would think that Storable would be a better choice, since it removes the need
for the 'eval'.  Not a big deal though.

- maybe a useful addition could be the ability to decide whether a runmode is
cachable from within the runmode itself.  something like this would do:

sub my_runmode {
  my $self = shift;

  $self->cachable(0);  # This runmode IS NOT cachable
  # - or -
  $self->cachable(1);  # This runmode IS cachable
}

It would make sense to make the default be that all runmodes are cached, but
this would allow the runmode to decide whether it is cachable.  It looks like
this is possible already through a custom cache_key method, but this might be
another simple way to achieve it.

Overall it looks like a great module that I hope to see on CPAN someday soon.

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.