CGI::Cache

CGI::Cache is a Perl extension to help cache output of time-intensive CGI scripts.
Download

CGI::Cache Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Broc Seib
  • Publisher web site:
  • http://search.cpan.org/~dcoppit/

CGI::Cache Tags


CGI::Cache Description

CGI::Cache is a Perl extension to help cache output of time-intensive CGI scripts. CGI::Cache is a Perl extension to help cache output of time-intensive CGI scripts.WARNINGThe interface as of version 1.01 has changed considerably and is NOT compatible with earlier versions. A smaller interface change also occurred in version 1.20.SYNOPSISHere's a simple example: #!/usr/bin/perl use CGI; use CGI::Cache; # Set up cache CGI::Cache::setup(); my $cgi = new CGI; # CGI::Vars requires CGI version 2.50 or better CGI::Cache::set_key($cgi->Vars); # This should short-circuit the rest of the loop if a cache value is # already there CGI::Cache::start() or exit; print $cgi->header, "n"; print < body > < p > This prints to STDOUT, which will be cached. If the next visit is within 24 hours, the cached STDOUT will be served instead of executing this 'print'. < /body >< /html > EOFHere's a more complex example: use CGI; use CGI::Cache; my $query = new CGI; # Set up a cache in /tmp/CGI_Cache/demo_cgi, with publicly # unreadable cache entries, a maximum size of 20 megabytes, # and a time-to-live of 6 hours. CGI::Cache::setup( { cache_options => { cache_root => '/tmp/CGI_Cache', namespace => 'demo_cgi', directory_umask => 077, max_size => 20 * 1024 * 1024, default_expires_in => '6 hours', } } ); # CGI::Vars requires CGI version 2.50 or better CGI::Cache::set_key( $query->Vars ); CGI::Cache::invalidate_cache_entry() if $query->param( 'force_regenerate' ) eq 'true'; CGI::Cache::start() or exit; print "Content-type: text/htmlnn"; print < body > < p > This prints to STDOUT, which will be cached. If the next visit is within 6 hours, the cached STDOUT will be served instead of executing these 'prints'. < /p > EOF CGI::Cache::pause(); print Requirements: · Perl


CGI::Cache Related Software