-
Notifications
You must be signed in to change notification settings - Fork 28
Session
donglei edited this page Jul 18, 2016
·
3 revisions
因为HTTP请求是无状态, Session可以提供在不同请求之间在服务端保存一些信息。
auto session = request.getSession();
session.set("username", "hello world");
session.get("username");
hunt中默认支持基于文件存储的Session机制;如果需要自定义,可以实现【SessionStorageInterface】接口,并注册到应用中即可,代码如下:
import hunt.http.sessionstorage;
class RedisSessionStorage : SessionStorageInterface
{
.....
}
static this()
{
SessionStorageInterface redisStorage()
{
return new RedisSessionStorage();
}
import std.functional;
newStorage = toDelegate(&redisStorage);
}