一.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这种。