Skip to content

Instantly share code, notes, and snippets.

@nikita-d
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikita-d/0282b245e8ea21cafe39 to your computer and use it in GitHub Desktop.
Save nikita-d/0282b245e8ea21cafe39 to your computer and use it in GitHub Desktop.
sub load {
my ($self, $sid) = @_;
my $redis = $self->redis();
my $prefix = $self->redis_prefix;
my $session;
my $delay = Mojo::IOLoop->delay(
sub {
my ($d, $res) = @_;
$res->{'data'} = $res->{'data'} ? decode_json($res->{'data'}) : undef ;
warn p $res;
$session = $res;
});
$redis->hgetall("$prefix/$sid", $delay->begin);
$delay->wait unless Mojo::IOLoop->is_running;
warn p [ $session->{'expires'}, $session->{'data'} ];;
return ( $session->{'expires'}, $session->{'data'} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment