またダブルセッションで共有

1708 ワード

前に2つのspringboot分布式のsession共有ソリューションを書いたことがあります.「springbootにおけるredisの使用と分布式session共有問題」と「session共有の再談」を参考に、同僚の共同研究を経て、springbootは別のソリューションを提供していました.0行コードソリューション
プロファイル
spring.session.redis.namespace=         
spring.session.store-type=redis

はい、この2行だけでいいです.他の構成やコード実装は必要ありません.テスト方法は上記の2つの文章を参照してください.
TIPS:1、redisを使用してセッション共有を解決する場合、shiroが持参したセッションマネージャなどの他のセッションマネージャを使用することはできません.そうしないと、上記の構成が失効します.2、上記の構成でタイムアウト構成が提供されていません.redisタイムアウトはserverを使用することができます.session.timeout=1800実装
springbootを添付し、別のセッション管理メカニズムを提供
# SPRING SESSION ([SessionProperties](https://github.com/spring-projects/spring-boot/tree/v1.5.9.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java))
spring.session.hazelcast.flush-mode=on-save # Sessions flush mode.
spring.session.hazelcast.map-name=spring:session:sessions # Name of the map used to store sessions.
spring.session.jdbc.initializer.enabled= # Create the required session tables on startup if necessary. Enabled automatically if the default table name is set or a custom schema is configured.
spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions.
spring.session.mongo.collection-name=sessions # Collection name used to store sessions.
spring.session.redis.flush-mode=on-save # Sessions flush mode.
spring.session.redis.namespace= # Namespace for keys used to store sessions.
spring.session.store-type= # Session store type.