NAME

Method::Cached::Manager - Storage for cache used in Method::Cached is managed

SYNOPSIS

SETTING OF CACHED DOMAIN

In beginning logic or the start-up script:

use Method::Cached::Manager;

Method::Cached::Manager->default_domain({
    class => 'Cache::FastMmap',
});

Method::Cached::Manager->set_domain(
    'some-namespace' => {
        class => 'Cache::Memcached::Fast',
        args  => [
            {
                # Parameter of constructor of class that uses it for cashe
                servers => [ '192.168.254.2:11211', '192.168.254.3:11211' ],
                ...
            },
        ],
    },
);

or

use Method::Cached::Manager
    -default => { class => 'Cache::FastMmap' },
    -domains => {
        'some-namespace' => { class => 'Cache::Memcached::Fast', args => [ ... ] },
    },
;

DESCRIPTION

Storage for cache used in Method::Cached is managed.

Cache used by default when not specifying it and cache that can be used by specifying the domain can be defined.

This setting is shared on memory management in perl.

METHODS

import ('-default' = {}, '-domains' => {})>
default_domain ( { class = CLASS_NAME, args => CLASS_ARGS } )>
set_domain ( DOMAIN_NAME = { class => CLASS_NAME, args => CLASS_ARGS } )>
get_domain ( DOMAIN_NAME )
delete ( METHOD_FQN, METHOD_ARGS [, ...] )

When it is defined in the package as follows:

package Foo::Bar;
use Method::Cached;
sub foo_bar :Cached(60 * 30, [HASH]) { ... }

This method is used as follows:

Foo::Bar::foo_bar(args1 => 1, args2 => 2);

To erase a cache of this method:

Method::Cached::Manager->delete(
    'Foo::Bar::foo_bar',       # fqn
    (args1 => 1, args2 => 2),  # hash-args
);

AUTHOR

Satoshi Ohkubo <s.ohkubo@gmail.com>

LICENSE

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