Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring session with in memory store

Why does not spring.session.store-type has in memory option. ?

Is there any way to use spring session with in memory option without writing my implementation of store ?

I would like to use spring session for rest api with token

 @Bean
  public HttpSessionIdResolver httpSessionIdResolver() {
    return HeaderHttpSessionIdResolver.xAuthToken();
  }
like image 798
user1321466 Avatar asked Jan 18 '19 07:01

user1321466


People also ask

Where does spring store session data?

Spring Session Hazelcast By default Apache Tomcat store objects in memory for HTTP session management. Moreover, in order to manage Spring Boot Session Management, the HTTPSession will be used to store session information with persistent storage (Mysql) by using Spring Session JDBC.

How does Spring maintain session?

Spring Session has the simple goal of free up session management from the limitations of the HTTP session stored in the server. The solution makes it easy to share session data between services in the cloud without being tied to a single container (i.e. Tomcat).


1 Answers

I found solution, there is a MapSessionRepository which can accept map. here is a documentation EnableSpringHttpSession

@EnableSpringHttpSession
@Configuration
public class SpringHttpSessionConfig {
    @Bean
    public MapSessionRepository sessionRepository() {
        return new MapSessionRepository(new ConcurrentHashMap<>());
    }
}
like image 66
user1321466 Avatar answered Oct 17 '22 07:10

user1321466