redisson教程java,Tomcat集群会话共享 - Redisson

一.Tomcat配置Redisson管理器

$catalina_home/conf/context.xml当中指定redisson:

二.创建Redisson配置信息

redission-single.json内容:单redis情况

{

"singleServerConfig": {

"idleConnectionTimeout": 10000,

"pingTimeout": 1000,

"connectTimeout": 10000,

"timeout": 3000,

"retryAttempts": 3,

"retryInterval": 1500,

"password": null,

"subscriptionsPerConnection": 5,

"clientName": null,

"address": "redis://redis:6379",

"subscriptionConnectionMinimumIdleSize": 1,

"subscriptionConnectionPoolSize": 50,

"connectionMinimumIdleSize": 32,

"connectionPoolSize": 64,

"database": 0,

"dnsMonitoringInterval": 5000

},

"threads": 0,

"nettyThreads": 0,

"codec": {

"class": "org.redisson.codec.SerializationCodec"

},

"transportMode": "NIO"

}

redission-cluster.json内容:多redis情况,只需配置从redis地址

{

"clusterServersConfig": {

"idleConnectionTimeout": 10000,

"pingTimeout": 1000,

"connectTimeout": 10000,

"timeout": 3000,

"retryAttempts": 3,

"retryInterval": 1500,

"failedSlaveReconnectionInterval": 3000,

"failedSlaveCheckInterval": 60000,

"password": null,

"subscriptionsPerConnection": 5,

"clientName": null,

"loadBalancer": {

"class": "org.redisson.connection.balancer.RoundRobinLoadBalancer"

},

"subscriptionConnectionMinimumIdleSize": 1,

"subscriptionConnectionPoolSize": 50,

"slaveConnectionMinimumIdleSize": 32,

"slaveConnectionPoolSize": 64,

"masterConnectionMinimumIdleSize": 32,

"masterConnectionPoolSize": 64,

"readMode": "SLAVE",

"subscriptionMode": "SLAVE",

"nodeAddresses": [

"redis://127.0.0.1:7004",

"redis://127.0.0.1:7001",

"redis://127.0.0.1:7000"

],

"scanInterval": 1000,

"pingConnectionInterval": 0,

"keepAlive": false,

"tcpNoDelay": false

},

"threads": 0,

"nettyThreads": 0,

"codec": {

"class": "org.redisson.codec.SerializationCodec"

},

"transportMode": "NIO"

}

tomcat中启用Redisson前提:在lib下面有下面的两个jar包: redisson-all-x.x.x.jar和redisson-tomcat-y-x.x.x.jar 实际存储的类型是hash,key类似redisson:tomcat_session:1CF4CF29EADCB3695FDB8E183B69A523这种。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值