Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved session performance slightly
  • Loading branch information
kraih committed Feb 6, 2012
1 parent 018f10c commit 0954c5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -505,9 +505,9 @@ Stop worker gracefully.
=back
=head1 CONFIGURATION
=head1 SETTINGS
L<Mojo::Server::Hypnotoad> can be configured with the following setting.
L<Mojo::Server::Hypnotoad> can be configured with the following settings.
# myapp.conf
{hypnotoad => {listen => ['http://*:3000'], workers => 10}};
Expand Down
21 changes: 8 additions & 13 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -436,22 +436,17 @@ sub send_message {
sub session {
my $self = shift;

# Get
my $stash = $self->stash;
my $session = $stash->{'mojo.session'};
if ($_[0] && !defined $_[1] && !ref $_[0]) {
return unless $session && ref $session eq 'HASH';
return $session->{$_[0]};
}

# Hash
$session = {} unless $session && ref $session eq 'HASH';
$stash->{'mojo.session'} = $session;
return $session unless @_;
my $stash = $self->stash;
$stash->{'mojo.session'} ||= {};
return $stash->{'mojo.session'} unless @_;

# Get
return $stash->{'mojo.session'}->{$_[0]} unless @_ > 1 || ref $_[0];

# Set
my $values = @_ > 1 ? {@_} : $_[0];
$stash->{'mojo.session'} = {%$session, %$values};
my $values = ref $_[0] ? $_[0] : {@_};
$stash->{'mojo.session'} = {%{$stash->{'mojo.session'}}, %$values};

return $self;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -81,7 +81,7 @@ You can tweak many configuration settings right from within your application.

app->start;

Or add a C<hypnotoad> section to your L<Mojolicious::Plugin::Config> or
Or just add a C<hypnotoad> section to your L<Mojolicious::Plugin::Config> or
L<Mojolicious::Config::JSONConfig> configuration file.

# myapp.conf
Expand Down

0 comments on commit 0954c5d

Please sign in to comment.