[Dancer-users] Dancer::Session::YAML initialises sessions dir for every new session

sawyer x xsawyerx at gmail.com
Sun May 1 14:01:58 CEST 2011


Thanks, Al, for notifying us of that.
We'll have it fixed soon enough. :)

On Thu, Apr 28, 2011 at 12:54 AM, Al <calyx2011 at gmail.com> wrote:

> Just a passing comment as I only use this module for testing purposes...
>
> I have noticed that Dancer::Session::YAML tries to initialize the
> sessions directory for every new session, causing the following log
> messages to appear repeatedly:
>
> [15144]  core @0.000064> session_dir : /home/al/dancertest/sessions in
> /usr/local/libdata/perl5/site_perl/Dancer/Session/YAML.pm l. 34
> [15144]  core @0.097106> [hit #2]session_dir :
> /home/al/dancertest/sessions in
> /usr/local/libdata/perl5/site_perl/Dancer/Session/YAML.pm l. 34
> [15144]  core @0.086822> [hit #8]session_dir :
> /home/al/dancertest/sessions in
> /usr/local/libdata/perl5/site_perl/Dancer/Session/YAML.pm l. 34
> [15144]  core @0.085747> [hit #14]session_dir :
> /home/al/dancertest/sessions in
> /usr/local/libdata/perl5/site_perl/Dancer/Session/YAML.pm l. 34
> [15144]  core @0.095747> [hit #19]session_dir :
> /home/al/dancertest/sessions in
> /usr/local/libdata/perl5/site_perl/Dancer/Session/YAML.pm l. 34
>
> This is inefficient and can be avoided by removing the following lines
> prepended with "x", so that the initialization code is run just once
> when the module is loaded by the "session" hook in Dancer::Config.
>
>  x17 sub init {
>  x18     my $self = shift;
>  x19     $self->SUPER::init(@_);
>  20
>  21     croak "YAML is needed and is not installed"
>  22       unless Dancer::ModuleLoader->load('YAML');
>  23
>  24     # default value for session_dir
>  25     setting('session_dir' => path(setting('appdir'), 'sessions'))
>  26       if not defined setting('session_dir');
>  27
>  28     # make sure session_dir exists
>  29     my $session_dir = setting('session_dir');
>  30     if (!-d $session_dir) {
>  31         mkdir $session_dir
>  32           or croak "session_dir $session_dir cannot be created";
>  33     }
>  34     Dancer::Logger::core("session_dir : $session_dir");
>  x35 }
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110501/3c9ada20/attachment.htm>


More information about the Dancer-users mailing list