| Egg-Plugin-SessionKit documentation | Contained in the Egg-Plugin-SessionKit distribution. |
Egg::Model::Session::Base::FileCache - Session management by Cache::FileCache.
package MyApp::Model::Sesion;
__PACKAGE__->config(
filecache => {
cache_root => MyApp->path_to('cache'),
namespace => 'sessions',
cache_depth => 3,
default_expires_in => (60* 60),
},
);
__PACKAGE__->startup(
Base::FileCache
ID::SHA1
Bind::Cookie
);
The session data is preserved by using Cache::FileCache.
And, 'Base::DBI' is added to startup of the component module generated with Egg::Helper::Model::Session. Default is this module.
There is no Store system component needing because Cache::FileCache can treat HASH well.
__PACKAGE__->startup( Base::FileCache ID::SHA1 Bind::Cookie );
'filecache' key is set to config of the session component module.
__PACKAGE__->config(
filecache => {
.......
},
);
All set items are passed to Cache::FileCache.
see Cache::FileCache.
Because most of these methods is the one that Egg::Model::Session internally uses it, it is not necessary to usually consider it on the application side.
The Cache::FileCache object is returned.
The session data obtained by received SESSION_ID is returned.
When SESSION_ID is not obtained, it acquires it in 'Session_id' method.
New session data is preserved.
SESSION_DATA is indispensable.
When SESSION_ID is not obtained, it acquires it in 'Session_id' method.
The same processing as 'insert' is done.
The session data is deleted.
SESSION_ID is indispensable.
$session->delete('abcdefghijkemn12345');
Egg::Release, Egg::Model::Session, Egg::Model::Session::Manager::Base, Egg::Model::Session::Manager::TieHash, Egg::Model, Cache::FileCache,
Masatoshi Mizuno <lushe&64;cpan.org>
Copyright (C) 2008 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.
| Egg-Plugin-SessionKit documentation | Contained in the Egg-Plugin-SessionKit distribution. |
package Egg::Model::Session::Base::FileCache; # # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> # # $Id: FileCache.pm 256 2008-02-14 21:07:38Z lushe $ # use strict; use warnings; use Cache::FileCache; use Carp qw/ croak /; our $VERSION= '3.00'; sub cache { $_[0]->attr->{cache} } sub _setup { my($class, $e)= @_; my $c= $class->config->{filecache} ||= {}; $c->{cache_root} ||= $e->config->{dir}{cache}; $c->{namespace} ||= do { my $pkg= ref($class) || $class; $pkg=~m{([^\:]+)\:+[^\:]+$}; "session_". lc($1); }; $c->{cache_depth} ||= 3; $c->{default_expires_in} ||= 60* 60; $class->next::method($e); } sub TIEHASH { my $self= shift->next::method(@_); $self->attr->{cache}= Cache::FileCache->new($self->config->{filecache}); $self; } sub restore { my $self= shift; my $id = shift || $self->session_id || croak q{I want session id.}; $self->cache->get($id) || 0; } sub insert { my $self= shift; my $data= shift || croak q{I want session data.}; my $id = shift || $self->session_id || croak q{I want session id.}; $self->cache->set($id, $data); } *update= \&insert; sub delete { my $self= shift; my $id= shift || croak q{I want session id.}; $self->cache->remove($id); $self; } 1; __END__