Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session在Redis存储模式下不支持MaxActive、MaxIdle等参数设置,默认设置在并发场景下导致Session读取为空 #236

Closed
mstmdev opened this issue Dec 18, 2020 · 1 comment

Comments

@mstmdev
Copy link

mstmdev commented Dec 18, 2020

Session在Redis存储模式下不支持自定义MaxActive、MaxIdle等参数设置,
默认MaxIdle=5,MaxActive=20,-->newPool函数,导致并发场景下Redis连接池耗尽,从而ctx.Session().Get("key"),获取有概率为nil,-->GetSessionState函数

devfeel added a commit that referenced this issue Dec 19, 2020
* fix: fixed can not set redis maxIdle & maxActive when use redis session, fix for issue #236
* refactor: add StoreConfig.MaxIdle & StoreConfig.MaxActive set redis maxIdle & maxActive
* refactor: add redisutil.GetDefaultRedisClient to returns the RedisClient of specified address
* refactor: update redisutil.GetRedisClient returns the RedisClient of specified address & maxIdle & maxActive
* opt: set defaultMaxIdle=10, defaultMaxActive=50 when use default redis config
* How to set redis maxIdle & maxActive when use redis session:
~~~ go
sessionConf := session.NewDefaultRedisConfig("redis://xx.xx.xx.xx:6379/0")
sessionConf.BackupServerUrl = "redis://xx.xx.xx.xx:6379/0"
sessionConf.CookieName = "dotweb-example.SessionID"
sessionConf.MaxIdle = 20
sessionConf.MaxActive = 100
~~~
* 2020-12-19 21:00 at ShangHai
devfeel added a commit that referenced this issue Dec 19, 2020
Version 1.7.14 fixed can not set redis maxIdle & maxActive when use redis session, fix for issue #236
@devfeel
Copy link
Owner

devfeel commented Dec 19, 2020

fixed it on version 1.7.14

@devfeel devfeel closed this as completed Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants