use of org.springframework.session.MapSession in project redisson by redisson.
the class RedissonSessionRepository method loadSession.
private MapSession loadSession(String sessionId) {
RMap<String, Object> map = redisson.getMap(keyPrefix + sessionId, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
Set<Entry<String, Object>> entrySet = map.readAllEntrySet();
if (entrySet.isEmpty()) {
return null;
}
MapSession delegate = new MapSession(sessionId);
for (Entry<String, Object> entry : entrySet) {
if ("session:creationTime".equals(entry.getKey())) {
delegate.setCreationTime(Instant.ofEpochMilli((Long) entry.getValue()));
} else if ("session:lastAccessedTime".equals(entry.getKey())) {
delegate.setLastAccessedTime(Instant.ofEpochMilli((Long) entry.getValue()));
} else if ("session:maxInactiveInterval".equals(entry.getKey())) {
delegate.setMaxInactiveInterval(Duration.ofSeconds((Long) entry.getValue()));
} else if (entry.getKey().startsWith(SESSION_ATTR_PREFIX)) {
delegate.setAttribute(entry.getKey().substring(SESSION_ATTR_PREFIX.length()), entry.getValue());
}
}
return delegate;
}
Aggregations