Java Code Examples for org.springframework.session.MapSession#isExpired()
The following examples show how to use
org.springframework.session.MapSession#isExpired() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonSessionRepository.java From redisson with Apache License 2.0 | 5 votes |
@Override public RedissonSession findById(String id) { MapSession mapSession = loadSession(id); if (mapSession == null || mapSession.isExpired()) { return null; } return new RedissonSession(mapSession); }
Example 2
Source File: HazelcastIndexedSessionRepository.java From spring-session with Apache License 2.0 | 5 votes |
@Override public HazelcastSession findById(String id) { MapSession saved = this.sessions.get(id); if (saved == null) { return null; } if (saved.isExpired()) { deleteById(saved.getId()); return null; } return new HazelcastSession(saved, false); }
Example 3
Source File: RedisSessionRepository.java From spring-session with Apache License 2.0 | 5 votes |
@Override public RedisSession findById(String sessionId) { String key = getSessionKey(sessionId); Map<String, Object> entries = this.sessionRedisOperations.<String, Object>opsForHash().entries(key); if (entries.isEmpty()) { return null; } MapSession session = new RedisSessionMapper(sessionId).apply(entries); if (session.isExpired()) { deleteById(sessionId); return null; } return new RedisSession(session, false); }
Example 4
Source File: RedisIndexedSessionRepository.java From spring-session with Apache License 2.0 | 5 votes |
/** * Gets the session. * @param id the session id * @param allowExpired if true, will also include expired sessions that have not been * deleted. If false, will ensure expired sessions are not returned. * @return the Redis session */ private RedisSession getSession(String id, boolean allowExpired) { Map<Object, Object> entries = getSessionBoundHashOperations(id).entries(); if (entries.isEmpty()) { return null; } MapSession loaded = loadSession(id, entries); if (!allowExpired && loaded.isExpired()) { return null; } RedisSession result = new RedisSession(loaded, false); result.originalLastAccessTime = loaded.getLastAccessedTime(); return result; }