public class HcastSessionStore extends Object implements Session.Store
Session.Store
powered by Hazelcast.
{ use(new Hcast()); session(HcastSessionStore.class); get("/", req -> { req.session().set("name", "jooby"); }); }
By default, a hazelcast session will expire after 30 minutes
. Changing the default timeout is as simple as:
# 8 hours session.timeout = 8h # 15 seconds session.timeout = 15 # 120 minutes session.timeout = 120m # no timeout session.timeout = -1
Default session's name is sessions
. It's possible to change the default name by setting the property: hazelcast.sesssion.name
.
rnd
Constructor and Description |
---|
HcastSessionStore(com.hazelcast.core.HazelcastInstance hazelcast, String name, int timeout)
Creates a new HcastSessionStore .
|
HcastSessionStore(com.hazelcast.core.HazelcastInstance hazelcast, String name, String timeout)
Creates a new HcastSessionStore .
|
Modifier and Type | Method and Description |
---|---|
void |
create(Session session) |
void |
delete(String id)
Delete a session by ID.
|
Session |
get(Session.Builder builder)
Get a session by ID (if any).
|
void |
save(Session session)
Save/persist a session.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateID
@Inject public HcastSessionStore(com.hazelcast.core.HazelcastInstance hazelcast, @Named(value="hazelcast.session.name") String name, @Named(value="hazelcast.session.timeout") String timeout)
HcastSessionStore
.
hazelcast
- Hazelcast instance.
name
- Session name.
timeout
- Session timeout expression, like 30m
.
public HcastSessionStore(com.hazelcast.core.HazelcastInstance hazelcast, String name, int timeout)
HcastSessionStore
.
hazelcast
- Hazelcast instance.
name
- Session name.
timeout
- Session timeout in seconds.
public Session get(Session.Builder builder)
Session.Store
get
in interface Session.Store
builder
- A session builder.
null
.
public void save(Session session)
Session.Store
save
in interface Session.Store
session
- A session to be persisted.
public void create(Session session)
create
in interface Session.Store
public void delete(String id)
Session.Store
delete
in interface Session.Store
id
- A session ID.
Copyright © 2019. All rights reserved.