Class RedisIndexedSessionRepository.RedisSession
java.lang.Object
org.springframework.session.data.redis.RedisIndexedSessionRepository.RedisSession
- All Implemented Interfaces:
Session
- Enclosing class:
- RedisIndexedSessionRepository
A custom implementation of
Session
that uses a MapSession
as the
basis for its mapping. It keeps track of any attributes that have changed. When
saveDelta()
is invoked all the
attributes that have been changed will be persisted.-
Method Summary
Modifier and TypeMethodDescriptionChanges the session id.<T> T
getAttribute
(String attributeName) Gets the Object associated with the specified name or null if no Object is associated to that name.Gets the attribute names that have a value associated with it.Gets the time when this session was created.getId()
Gets a unique string that identifies theSession
.Gets the last time thisSession
was accessed.Gets the maximum inactive interval between requests before this session will be invalidated.boolean
Returns true if the session is expired.void
removeAttribute
(String attributeName) Removes the attribute with the provided attribute name.void
setAttribute
(String attributeName, Object attributeValue) Sets the attribute value for the provided attribute name.void
setLastAccessedTime
(Instant lastAccessedTime) Sets the last accessed time.void
setMaxInactiveInterval
(Duration interval) Sets the maximum inactive interval between requests before this session will be invalidated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.session.Session
getAttributeOrDefault, getRequiredAttribute
-
Method Details
-
setLastAccessedTime
Description copied from interface:Session
Sets the last accessed time.- Specified by:
setLastAccessedTime
in interfaceSession
- Parameters:
lastAccessedTime
- the last accessed time
-
isExpired
public boolean isExpired()Description copied from interface:Session
Returns true if the session is expired. -
getCreationTime
Description copied from interface:Session
Gets the time when this session was created.- Specified by:
getCreationTime
in interfaceSession
- Returns:
- the time when this session was created.
-
getId
Description copied from interface:Session
Gets a unique string that identifies theSession
. -
changeSessionId
Description copied from interface:Session
Changes the session id. After invoking theSession.getId()
will return a new identifier.- Specified by:
changeSessionId
in interfaceSession
- Returns:
- the new session id which
Session.getId()
will now return
-
getLastAccessedTime
Description copied from interface:Session
Gets the last time thisSession
was accessed.- Specified by:
getLastAccessedTime
in interfaceSession
- Returns:
- the last time the client sent a request associated with the session
-
setMaxInactiveInterval
Description copied from interface:Session
Sets the maximum inactive interval between requests before this session will be invalidated. A negative time indicates that the session will never timeout.- Specified by:
setMaxInactiveInterval
in interfaceSession
- Parameters:
interval
- the amount of time that theSession
should be kept alive between client requests.
-
getMaxInactiveInterval
Description copied from interface:Session
Gets the maximum inactive interval between requests before this session will be invalidated. A negative time indicates that the session will never timeout.- Specified by:
getMaxInactiveInterval
in interfaceSession
- Returns:
- the maximum inactive interval between requests before this session will be invalidated. A negative time indicates that the session will never timeout.
-
getAttribute
Description copied from interface:Session
Gets the Object associated with the specified name or null if no Object is associated to that name.- Specified by:
getAttribute
in interfaceSession
- Type Parameters:
T
- the return type of the attribute- Parameters:
attributeName
- the name of the attribute to get- Returns:
- the Object associated with the specified name or null if no Object is associated to that name
-
getAttributeNames
Description copied from interface:Session
Gets the attribute names that have a value associated with it. Each value can be passed intoSession.getAttribute(String)
to obtain the attribute value.- Specified by:
getAttributeNames
in interfaceSession
- Returns:
- the attribute names that have a value associated with it.
- See Also:
-
setAttribute
Description copied from interface:Session
Sets the attribute value for the provided attribute name. If the attributeValue is null, it has the same result as removing the attribute withSession.removeAttribute(String)
.- Specified by:
setAttribute
in interfaceSession
- Parameters:
attributeName
- the attribute name to setattributeValue
- the value of the attribute to set. If null, the attribute will be removed.
-
removeAttribute
Description copied from interface:Session
Removes the attribute with the provided attribute name.- Specified by:
removeAttribute
in interfaceSession
- Parameters:
attributeName
- the name of the attribute to remove
-