Created
March 24, 2015 08:10
-
-
Save kfly8/26b89de2af11d40a4bae to your computer and use it in GitHub Desktop.
session の finalizeがもたもた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use Amon2::Lite; | |
use Cache::Memcached::Fast; | |
use Plack::Session::Store::Cache; | |
get '/' => sub { | |
my $c = shift; | |
return $c->render('index.tt'); | |
}; | |
get '/usagi' => sub { | |
my $c = shift; | |
warn sprintf('/usagi time usagi:%s, kame: %s', $c->session->get('usagi.time')||'', $c->session->get('kame.time')||'',); | |
$c->session->set('usagi.time' => time); | |
# session の finalize までもたもたしている | |
sleep 1; | |
return $c->render('usagi.tt'); | |
}; | |
get '/kame' => sub { | |
my $c = shift; | |
warn sprintf('/usagi time usagi:%s, kame: %s', $c->session->get('usagi.time')||'', $c->session->get('kame.time')||'',); | |
$c->session->set('kame.time' => time); | |
return $c->render('kame.tt'); | |
}; | |
__PACKAGE__->enable_session( | |
store => Plack::Session::Store::Cache->new( | |
cache => Cache::Memcached::Fast->new(+{ | |
servers => ['127.0.0.1:11211'], | |
}), | |
) | |
); | |
__PACKAGE__->to_app(); | |
__DATA__ | |
@@ index.tt | |
<!doctype html> | |
<html> | |
<head> | |
<title>usagi vs kame</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<h1>usagi vs kame</h1> | |
<script> | |
$.get('/usagi', function(data) { console.log(data) }); | |
$.get('/kame', function(data) { console.log(data) }); | |
</script> | |
</body> | |
</html> | |
@@ usagi.tt | |
usagi | |
@@ kame.tt | |
kame | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment