Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
shuaje committed Dec 25, 2017
1 parent 738e201 commit 1160a0b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.data.redis.core.types.Expiration;

import top.ibase4j.core.util.InstanceUtil;
import top.ibase4j.core.util.PropertiesUtil;
import top.ibase4j.core.util.SerializeUtil;

/**
Expand Down Expand Up @@ -86,9 +87,9 @@ protected Session doReadSession(Serializable sessionId) {
private void saveSession(Session session) {
if (session == null || session.getId() == null) throw new UnknownSessionException("session is empty");
byte[] sessionKey = buildRedisSessionKey(session.getId());
Long sessionTimeOut = session.getTimeout() / 1000 + EXPIRE_TIME;
int sessionTimeOut = PropertiesUtil.getInt("session.maxInactiveInterval", EXPIRE_TIME);
byte[] value = SerializeUtil.serialize(session);
getRedisConnection().set(sessionKey, value, Expiration.seconds(sessionTimeOut.intValue()), SetOption.UPSERT);
getRedisConnection().set(sessionKey, value, Expiration.seconds(sessionTimeOut), SetOption.UPSERT);
}

private byte[] buildRedisSessionKey(Serializable sessionId) {
Expand Down

0 comments on commit 1160a0b

Please sign in to comment.