public class Neo4jSessionStore extends Object implements Session.Store
Session.Store
powered by Neo4j.
{ session(Neo4jSessionStore.class); get("/", req -> { req.session().set("name", "jooby"); }); }The
name
attribute and value will be stored in a Neo4j.
By default, a neo4j 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
It uses GraphAware's Expire library to automatically remove expired sessions.
For embedded databases you need to configure the expire module, like:
com.graphaware.runtime.enabled = true com.graphaware.module = [{ class: com.graphaware.neo4j.expire.ExpirationModuleBootstrapper nodeExpirationProperty: _expire }]
The Neo4jSessionStore
uses the _expire
to evict sessions.
If you connect to a remote server make sure the expire module was installed. More information at .
If no timeout is required, use -1
.
It's possible to provide the session label using the neo4j.session.label
properties.
rnd
Constructor and Description |
---|
Neo4jSessionStore(iot.jcypher.database.IDBAccess dbaccess, String sessionLabel, long timeoutInSeconds) |
Neo4jSessionStore(iot.jcypher.database.IDBAccess dbaccess, String sessionLabel, 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 Neo4jSessionStore(iot.jcypher.database.IDBAccess dbaccess, String sessionLabel, long timeoutInSeconds)
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.