#!/usr/bin/perl -w

use strict;
use Template;
$| = 1;

my $template = <<EOM;
[% USE cache = Cache %]
[% BLOCK cache_me %]
-----------------------
  About to do a lot of work...
  [% PERL %]
    sleep 5;
  [% END %]
  And now to demonstrate that the keys matter:
                 Hello [% name %]
-----------------------
[% END %]
[% cache.inc(
             'template' => 'cache_me',
             'keys' => {'name' => name},
             'ttl' => 15
             ) %]
EOM

my $t = Template->new(
		      EVAL_PERL => 1,
		      ANYCASE   => 1,
		     );

print "first run with name = Suzanne";
$t->process(\$template, { name => 'Suzanne' }) || die $t->error();

print "second run with name = Suzanne\n\n";
$t->process(\$template, { name => 'Suzanne' }) || die $t->error();

print "first run with name = World\n\n";
$t->process(\$template, { name => 'World' }) || die $t->error();

print "second run with name = World\n\n";
$t->process(\$template, { name => 'World' }) || die $t->error();
