NAME
Method::Cached - The return value of the method is cached to your storage
SYNOPSIS
package Foo;
use Method::Cached;
sub cached :Cached { time . rand }
sub no_cached { time . rand }
package main;
my $test1 = { cached => Foo->cached, no_cached => Foo->no_cached };
sleep 1; # It is preferable that time passes in this test
my $test2 = { cached => Foo->cached, no_cached => Foo->no_cached };
is $test1->{cached}, $test2->{cached};
isnt $test1->{no_cached}, $test2->{no_cached};
DESCRIPTION
Method::Cached offers the following mechanisms:
The return value of the method is stored in storage, and the value stored when being execute it next time is returned.
SETTING OF CACHED DOMAIN
In beginning logic or the start-up script:
use Method::Cached::Manager
-default => { class => 'Cache::FastMmap' },
-domains => {
'some-namespace' => { class => 'Cache::Memcached::Fast', args => [ ... ] },
},
;
For more documentation on setting of cached domain, see Method::Cached::Manager.
DEFINITION OF METHODS
This function is mounting used as an attribute of the method.
- :Cached ( DOMAIN_NAME, EXPIRES, [, KEY_RULE, ...] )
-
The cached rule is defined specifying the domain name.
sub message :Cached('some-namespace', 60 * 5, LIST) { ... }
- :Cached ( EXPIRES, [, KEY_RULE, ...] )
-
When the domain name is omitted, the domain of default is used.
sub message :Cached(60 * 5, LIST) { ... }
RULE TO GENERATE KEY
- LIST
- HASH
- SELF_SHIFT
- PER_OBJECT
OPTIONAL, RULE TO GENERATE KEY
use Method::Cached::KeyRule::Serialize;
- SERIALIZE
- SELF_CODED
METHODS
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.