spring-session icon indicating copy to clipboard operation
spring-session copied to clipboard

why the 'RedisOperationsSessionRepository.RedisSession' is a inner class?

Open jintianxiayu opened this issue 9 years ago • 4 comments

why the 'RedisOperationsSessionRepository.RedisSession' is a inner class? as a resut I can not use the result of method:

public Map<String, RedisSession> findByIndexNameAndIndexValue(String indexName,
			String indexValue)

jintianxiayu avatar Mar 14 '17 10:03 jintianxiayu

RedisSession is an implementation of ExpiringSession that's specific to the RedisOperationsSessionRepository. That shouldn't prevent you from using the FindByIndexNameSessionRepository.

Here's a usage example from find by username sample app guide:

@Autowired
FindByIndexNameSessionRepository<? extends ExpiringSession> sessions;

@RequestMapping("/")
public String index(Principal principal, Model model) {
    Collection<? extends ExpiringSession> usersSessions = this.sessions
            .findByIndexNameAndIndexValue(
                    FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
                    principal.getName())
            .values();
    model.addAttribute("sessions", usersSessions);
    return "index";
}

vpavic avatar Mar 14 '17 18:03 vpavic

Closing as answered. If you have additional questions or feel that your original question isn't properly answered, please re-open the issue.

vpavic avatar Mar 20 '17 19:03 vpavic

How would you approach this if you want to save/update session ??

mrshawn191 avatar Jan 31 '18 16:01 mrshawn191

See #849 (comment).

vpavic avatar Aug 14 '18 09:08 vpavic