Catalyst::Plugin::Cache::Store::FastMmap - B<DEPRECATED> - FastMmap cache store


Catalyst-Plugin-Cache-Store-FastMmap documentation Contained in the Catalyst-Plugin-Cache-Store-FastMmap distribution.

Index


Code Index:

NAME

Top

Catalyst::Plugin::Cache::Store::FastMmap - DEPRECATED - FastMmap cache store for Catalyst::Plugin::Cache.

SYNOPSIS

Top

    # instead of using this plugin, you can now do this:

    use Catalyst qw/
        Cache
    /;

    __PACKAGE__->config( cache => {
        backend => {
            class => "Cache:FastMmap",
            share_file => "/path/to/file",
            cache_size => "16m",
        },
    });

STATUS

Top

This plugin is deprecated because Cache::FastMmap no longer needs to be wrapped to store plain values. It is still available on the CPAN for backwards compatibility and will still work with newer versions of Cache::FastMmap with a slight performance degredation.

DESCRIPTION

Top

This store plugin is a bit of a wrapper for Cache::FastMmap.

While you could normally just configure with

    backend => {
        class => "Cache::FastMmap",
        share_file => ...,
    }

Cache::FastMmap can't store plain values by default. This module ships with a subclass that will wrap all values in a scalar reference before storing.

This store plugin will try to provide a default share_file as well, that won't clash with other apps.

CONFIGURATION

Top

See CONFIGURATION in Catalyst::Plugin::Cache for a general overview of cache plugin configuration.

This plugin just takes a hash reference in the backend field and passes it on to Cache::FastMmap.

SEE ALSO

Top

Catalyst::Plugin::Cache, Cache::FastMmap.

AUTHOR

Top

Yuval Kogman, nothingmuch@woobling.org

COPYRIGHT & LICENSE

Top


Catalyst-Plugin-Cache-Store-FastMmap documentation Contained in the Catalyst-Plugin-Cache-Store-FastMmap distribution.

#!/usr/bin/perl

package Catalyst::Plugin::Cache::Store::FastMmap;

use strict;
use warnings;

our $VERSION = "0.02";

use Path::Class     ();
use File::Spec      ();
use Catalyst::Utils ();
use Catalyst::Plugin::Cache::Backend::FastMmap;

sub setup_fastmmap_cache_backend {
    my ( $app, $name, $config ) = @_;

    $config->{share_file} ||= File::Spec->catfile( Catalyst::Utils::class2tempdir($app), "cache_$name" );

    # make sure it exists
    Path::Class::file( $config->{share_file} )->parent->mkpath; 

    $app->register_cache_backend(
        $name => Catalyst::Plugin::Cache::Backend::FastMmap->new( %$config )
    );
}

__PACKAGE__;

__END__