Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

merlyn (47)

merlyn
  merlyn@stonehenge.com
http://www.stonehenge.com/merlyn/
AOL IM: realmerlyn (Add Buddy, Send Message)
Yahoo! ID: realmerlyn (Add User, Send Message)

PAUSE-ID: MERLYN [cpan.org].
See my home page [stonehenge.com].

Journal of merlyn (47)

Friday September 27, 2002
09:00 AM

CaChing

[ #8052 ]
OK, that was easier than I thought. I added

package Stonehenge::Template::Plugin::CacheFileCache;

use Cache::FileCache;
use base qw(Template::Plugin);

sub new {
  my $class = shift;
  my $context = shift;
  Cache::FileCache->new(@_);
}

1;

to my webserver's mod_perl search path, and

TT2PluginBase Stonehenge::Template::Plugin

to my config file, and now I can say:

  USE mycache = CacheFileCache({
    namespace => 'stonehenge-nav_stacked_bars',
    default_expires_in => 1800,
    auto_purge_interval => 1800,
  });
  mykey = [class, instance, global.navbardata.modtime];
  mykey = mykey.join(":");
  result = mycache.get(mykey);
  UNLESS result;
    result = BLOCK;
      [[ stuff to compute result deleted ]]
    END;
    mycache.set(mykey, result);
    FILTER stderr; "cache miss on "; mykey; "\n"; END;
  END;
  result;

to my navbar generation template, and I've just cached the creation of my navbars (function of class, instance, and the timestamp on the navbar data).

TT2 rocks. Cache::Cache rocks. 'nuff said.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.