Skip to content

Commit

Permalink
0.006 - Route caching
Browse files Browse the repository at this point in the history
  • Loading branch information
rawleyfowler committed Aug 5, 2023
1 parent 4fbd352 commit cd2d7a0
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.006 2023-08-03
- Alpha release #6
- Add Slick::Annotation
- Add route based caching based on "annotation"
- Various POD fixes

0.005 2023-08-03
- Alpha release #5
- Add Slick::Cache, Slick::CacheExecutor{,::Redis,::Memcached}
Expand Down
2 changes: 1 addition & 1 deletion lib/Slick.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use experimental qw(try);

no warnings qw(experimental::try);

our $VERSION = '0.005';
our $VERSION = '0.006';

with 'Slick::EventHandler';
with 'Slick::RouteManager';
Expand Down
80 changes: 80 additions & 0 deletions lib/Slick/Annotation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,83 @@ qq{Attempted to use cache $cache to cache route but cache does not exist.};
}

1;

=encoding utf8
=head1 NAME
Slick::Annotation
=head1 SYNOPSIS
A functional module for "annotations", simply functions that can compose
nicely to add functionality to routes.
=head1 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 L<Slick::Cache> for more information about
caching.
=head1 See also
=over2
=item * L<Slick::CacheExecutor>
=item * L<Slick::CacheExecutor::Redis>
=item * L<Slick::CacheExecutor::Memcached>
=item * L<Slick::Context>
=item * L<Slick::Database>
=item * L<Slick::DatabaseExecutor>
=item * L<Slick::DatabaseExecutor::MySQL>
=item * L<Slick::DatabaseExecutor::Pg>
=item * L<Slick::EventHandler>
=item * L<Slick::Events>
=item * L<Slick::Methods>
=item * L<Slick::RouteMap>
=item * L<Slick::Util>
=back
=cut
4 changes: 4 additions & 0 deletions t/01-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ use Test::More;
BEGIN {
use_ok 'Slick';
use_ok 'Slick::Error';
use_ok 'Slick::RouteMap';
use_ok 'Slick::Cache';
use_ok 'Slick::Database';
use_ok 'Slick::Router';
use_ok 'Slick::Annotation';
}

use Slick;
Expand Down

0 comments on commit cd2d7a0

Please sign in to comment.