public class JdbcSessionRepository extends Object implements SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>
SessionRepository implementation that uses
Database to store sessions in a relational database. This
implementation does not support publishing of session events.
An example of how to create a new instance can be seen below:
JdbcSessionRepository sessionRepository = new JdbcSessionRepository(dataSource);
Depending on your database, the table definition can be described as below:
CREATE TABLE light_session ( session_id VARCHAR2(100) NOT NULL, creation_time bigint NOT NULL, last_access_time bigint NOT NULL, max_inactive_interval int, expiry_time bigint, principal_name VARCHAR(100), PRIMARY KEY(session_id) ); CREATE TABLE light_session_attributes ( session_id VARCHAR2(100) NOT NULL, attribute_name VARCHAR(200) NOT NULL, attribute_bytes BYTEA, PRIMARY KEY(session_id, attribute_name) );
| Constructor and Description |
|---|
JdbcSessionRepository(DataSource dataSource) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUpExpiredSessions() |
com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession |
createSession() |
void |
deleteById(String id) |
List<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession> |
extractData(ResultSet rs) |
com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession |
findById(String id) |
Map<String,Session> |
getSessions() |
void |
save(com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession session) |
void |
setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval)
Set the maximum inactive interval in seconds between requests before newly created
sessions will be invalidated.
|
void |
updateSessionLastAccessTime(String id) |
public JdbcSessionRepository(DataSource dataSource)
public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval)
defaultMaxInactiveInterval - the maximum inactive interval in secondspublic com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession createSession()
createSession in interface SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>public void save(com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession session)
save in interface SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>public com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession findById(String id)
findById in interface SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>public void deleteById(String id)
deleteById in interface SessionRepository<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession>public void cleanUpExpiredSessions()
public void updateSessionLastAccessTime(String id)
public List<com.networknt.session.jdbc.JdbcSessionRepository.JdbcSession> extractData(ResultSet rs) throws SQLException
SQLExceptionCopyright © 2019. All rights reserved.