public class CassandraSessionStore extends Object implements Session.Store
A Session.Store
powered by Cassandra.
{
use(new Cassandra("cassandra://localhost/db"));
session(CassandraSessionStore.class);
get("/", req -> {
Session session = req.session();
session.put("foo", "bar");
..
});
}
Session data is persisted in Cassandra using a session
table.
By default, a 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
Expiration is done via Cassandra ttl option.
If no timeout is required, use -1
.
rnd
Constructor and Description |
---|
CassandraSessionStore(com.datastax.driver.core.Session session, int timeout) |
CassandraSessionStore(com.datastax.driver.core.Session session, String timeout) |
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
public CassandraSessionStore(com.datastax.driver.core.Session session, int timeout)
@Inject public CassandraSessionStore(com.datastax.driver.core.Session session, @Named(value="session.timeout") String timeout)
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.