Dancer::Plugin::Cache - Dancer plugin to cache response content [DEPRECATED]


Back to Top


NAME

Dancer::Plugin::Cache - Dancer plugin to cache response content (and anything else) [DEPRECATED]

Back to Top


VERSION

version 0.2.2

Back to Top


SYNOPSIS

In your configuration:

    plugins:
        Cache:
            driver: Memory
            global: 1

In your application:

    use Dancer ':syntax';
    use Dancer::Plugin::Cache;
    # caching pages' response
    
    check_page_cache;
    get '/cache_me' => sub {
        cache_page template 'foo';
    };
    # using the helper functions
    get '/clear' => sub {
        cache_clear;
    };
    put '/stash' => sub {
        cache_set secret_stash => request->body;
    };
    get '/stash' => sub {
        return cache_get 'secret_stash';
    };
    # using the cache directly
    get '/something' => sub {
        my $thingy = cache->compute( 'thingy', sub { compute_thingy() } );
        return template 'foo' => { thingy => $thingy };
            };

Back to Top


DESCRIPTION

DEPRECATED: this module has been renamed to the Dancer::Plugin::Cache::CHI manpage.

This plugin provides Dancer with an interface to a CHI cache. Also, it includes a mechanism to easily cache the response of routes.

Back to Top


CONFIGURATION

The plugin's configuration is passed directly to the CHI object's constructor. For example, the configuration given in the SYNOPSIS will create a cache object equivalent to

    $cache = CHI->new( driver => 'Memory', global => 1, );

Back to Top


KEYWORDS

cache

Returns the CHI cache object.

check_page_cache

If invoked, returns the cached response of a route, if available.

The path_info attribute of the request is used as the key for the route, so the same route requested with different parameters will yield the same cached content. Caveat emptor.

cache_page($content, $expiration)

Caches the $content to be served to subsequent requests. The $expiration parameter is optional.

cache_set, cache_get, cache_clear, cache_compute

Shortcut to the cache's object methods.

    get '/cache/:attr/:value' => sub {
        # equivalent to cache->set( ... );
        cache_set $params->{attr} => $params->{value};
    };

Back to Top


SEE ALSO

Dancer Web Framework - Dancer

the Dancer::Plugin::Cache::CHI manpage - the new incarnation of this module.

the Dancer::Plugin::Memcached manpage - plugin that heavily inspired this one.

Back to Top


AUTHOR

Yanick Champoux <yanick@cpan.org>

Back to Top


COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Back to Top

 Dancer::Plugin::Cache - Dancer plugin to cache response content [DEPRECATED]