NAME
Egg::Plugin::Cache - cache for Egg plugin.
SYNOPSIS
use Egg qw/ Cache /;
package MyApp::Cache::MyCache;
__PACKAGE__->include('Cache::FileCache');
__PACKAGE__->config(
namespace => 'TestTest',
cache_root => '/path/to/MyApp/cache',
cache_depth => 3,
default_expires_in => 3600,
);
# The cashe object is acquired.
my $cache= $e->cache('MyCache');
# The data that has been cached is acquired.
my $data = $cache->get('cache_key');
# Data is set in the cache.
$cache->set( cache_key => $data );
DESCRIPTION
It is a plugin to treat cashe.
An arbitrary cashe module can be used as a cashe driver.
A special cashe controller is necessary in each cashe driver that uses it.
The cashe controller is generable by the use of Egg::Helper::Plugin::Cache.
% perl MyApp/bin/myapp_helper.pl Plugin:Cache [NEW_CACHE_NAME]
Default driver of generated cashe controller Cache::FileCache. Please change this when you want to load other cashe modules.
HASH set in config is passed by the reference as it is by the constructor of the cashe module.
Please refer to the document of the module used for the method of setting config.
METHODS
cache ( [CACHE_NAME] )
The handler object of CACHE_NAME is returned.
CACHE_NAME is cashe controller's name.
my $cache= $e->cache('CacheControllerName');
HANDLER METHODS
cache
The object of the cashe module read as a driver is returned.
It calls it through this method if there is a peculiar method to the cashe module.
$e->cache('CacheName')->cache;
new
Constructor who returns handler object.
get, set, clear, remove, purge
It is an accessor to the cashe driver.
If it is a method not being supported by the cashe driver, the exception is generated.
my $data= $e->cache('CacheName')->get('cache_key');
SEE ALSO
Cache::FileCache, Egg::Helper::Plugin::Cache, Egg::Release,
AUTHOR
Masatoshi Mizuno <lushe@cpan.org>
COPYRIGHT
Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.