NAME
Slick::Annotation
SYNOPSIS
A functional module for "annotations", simply functions that can compose nicely to add functionality to routes.
cacheable
use 5.036;
use Slick;
use Slick::Annotation qw(cacheable);
my $s = Slick->new;
# See Redis and Cache::Memcached on CPAN for arguments
# Create a Redis instance
$s->cache(
my_redis => type => 'redis', # Slick Arguments
server => '127.0.0.1:6379' # Cache::Memcached arguments
);
# Use your cache to cache your route
$s->get(
'/foobar' => cacheable(
'my_redis', # cache name
sub {
my ( $app, $context ) = @_;
return $context->json( { foo => 'bar' } );
}
)
);
$s->run;
Declares a route sub-routine as "cacheable" meaning it will always return the same response, and retrieve that response from a specified cache. See Slick::Cache for more information about caching.
See also
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 102:
Unknown directive: =over2
- Around line 104:
'=item' outside of any '=over'