使用 Spring Session Redis 的一些思考

1. 项目搭建

搭建 springboot 项目

创建启动类 SpringbootDemoApplication

@SpringBootApplication
// 开启使用 redis 存储 session
@EnableRedisHttpSession
public class SpringbootDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringbootDemoApplication.class, args);
    }
}

创建一个请求类 TestSpringSessionController

@RestController
public class TestSpringSessionController {

    @GetMapping("/")
    public String getName(HttpServletRequest request) {
        HttpSession session = request.getSession();
        session.setAttribute("uid", "10001");
        session.setAttribute("username", "test");
        return session.getId();
    }

}

配置

# session 存储使用 redis
spring.session.store-type=redis

# redis 连接信息
spring.redis.host=localhost
spring.redis.password=
spring.redis.port=6379

# 打印 spring-data-redis 日志
logging.level.io.lettuce.core=debug
logging.level.org.springframework.data.redis.core=debug

添加主要的依赖包

   <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
		
		<!-- redis 管理 session 的 jar 包 -->
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-data-redis</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>
        
    </dependencies>

2. 测试

请求

http://localhost:8080

响应

c99f4c3b-4956-4a7a-90ba-0896648e8d54

可以查看redis中数据
redis中的数据
其中重点关注第二个key 中的数据,第一个和第三个这里先不关注,后续会介绍其作用
session中存储的数据
可以看到里面包含自定义的 username,uid,即 session 的数据确实存储在redis中了,结果是正确的。

3. 日志分析

在这个请求过程中,配置了 debug 日志打印,可以看到以下结果

2019-07-08 17:42:53.333 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.334 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.334 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.334 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.334 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.335 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.336 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.336 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.336 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.336 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HGETALL, output=MapOutput [output={}, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.336 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.375 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.376 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.376 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.376 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.376 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.377 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.378 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 5 bytes, 1 commands in the stack
2019-07-08 17:42:53.378 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.378 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.378 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HMSET, output=StatusOutput [output=OK, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.379 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.381 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.382 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.382 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.383 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.383 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.383 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.385 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.386 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.386 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.386 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=SADD, output=IntegerOutput [output=1, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.386 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.387 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.389 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.389 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.390 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.390 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.390 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.391 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.391 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.391 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.391 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=true, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.391 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.393 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.394 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.394 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.394 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.394 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.394 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.395 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.396 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.396 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.396 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=APPEND, output=IntegerOutput [output=0, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.396 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.396 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.396 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.396 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.396 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.396 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.397 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.398 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.398 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.398 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.398 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=true, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.398 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.398 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.398 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.398 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.398 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.398 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.399 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.400 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.400 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.400 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.400 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=true, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.400 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.401 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.401 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.401 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.401 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.402 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.402 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-2] io.lettuce.core.protocol.CommandHandler  : [channel=0x19e9f9d2, /127.0.0.1:51115 -> localhost/127.0.0.1:6379, chid=0x2] Received: 216 bytes, 0 commands in the stack
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-2] i.l.core.protocol.RedisStateMachine      : Decode null
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PUBLISH, output=IntegerOutput [output=1, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.403 DEBUG 53842 --- [ioEventLoop-4-2] i.l.core.protocol.RedisStateMachine      : Decoded null, empty stack: true
2019-07-08 17:42:53.403 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:42:53.403 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:42:53.403 DEBUG 53842 --- [nio-8080-exec-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.403 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.404 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:42:53.404 DEBUG 53842 --- [nio-8080-exec-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:42:53.404 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.405 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:42:53.405 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:42:53.405 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:42:53.405 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HGETALL, output=MapOutput [output={}, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:42:53.406 DEBUG 53842 --- [nio-8080-exec-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection

这个日志,是当 session 在 redis 中不存在时,第一次请求的日志,从日志中查看到,这个过程中发生 9 次 redis 操作,分别是:

HGETALL
HMSET
SADD
PEXPIRE
APPEND
PEXPIRE
PEXPIRE
PUBLISH
HGETALL

当 redis 中已经存在 session 时,日志打印如下:

2019-07-08 17:44:45.344 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.344 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.345 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.345 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.345 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.345 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.347 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 338 bytes, 1 commands in the stack
2019-07-08 17:44:45.348 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.348 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.348 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HGETALL, output=MapOutput [output={[B@5702d204=[B@6e2e98bd, [B@5095bdbf=[B@2f7df58e, [B@60bc5aa4=[B@52f8dd9b}, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.348 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.351 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.352 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.352 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.352 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.352 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.353 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.354 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 5 bytes, 1 commands in the stack
2019-07-08 17:44:45.354 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.354 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HMSET, output=StatusOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.354 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HMSET, output=StatusOutput [output=OK, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.354 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.355 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.356 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=SREM, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.356 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=SREM, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.356 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.356 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=SREM, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.357 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=SREM, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-2] io.lettuce.core.protocol.CommandHandler  : [channel=0x19e9f9d2, /127.0.0.1:51115 -> localhost/127.0.0.1:6379, chid=0x2] Received: 113 bytes, 0 commands in the stack
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-2] i.l.core.protocol.RedisStateMachine      : Decode null
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=SREM, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=SREM, output=IntegerOutput [output=1, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.358 DEBUG 53842 --- [ioEventLoop-4-2] i.l.core.protocol.RedisStateMachine      : Decoded null, empty stack: true
2019-07-08 17:44:45.359 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.359 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.359 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.359 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.360 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.360 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.360 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.361 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:44:45.361 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.361 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=SADD, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.362 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=SADD, output=IntegerOutput [output=1, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.362 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.362 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.362 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.362 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.362 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.362 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.363 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.364 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:44:45.364 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.364 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.364 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=true, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.364 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.364 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.364 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.364 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.364 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.365 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.365 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.366 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:44:45.366 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.366 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=APPEND, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.366 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=APPEND, output=IntegerOutput [output=0, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.366 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.366 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.366 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.366 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.366 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.366 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.367 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.368 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:44:45.368 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.368 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.368 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=true, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.369 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.369 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.369 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.369 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.369 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.369 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.370 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.371 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-08 17:44:45.371 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.371 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.371 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=PEXPIRE, output=BooleanOutput [output=true, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.371 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.372 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.372 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.372 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.372 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.372 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.372 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.374 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 338 bytes, 1 commands in the stack
2019-07-08 17:44:45.374 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.374 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.374 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HGETALL, output=MapOutput [output={[B@5013c41a=[B@1ef30852, [B@4ae245d5=[B@508e2c82, [B@a730882=[B@89a07ab}, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.374 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-08 17:44:45.375 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-08 17:44:45.375 DEBUG 53842 --- [nio-8080-exec-5] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.375 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.375 DEBUG 53842 --- [nio-8080-exec-5] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-08 17:44:45.376 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-08 17:44:45.376 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.377 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Received: 338 bytes, 1 commands in the stack
2019-07-08 17:44:45.377 DEBUG 53842 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0x6de23885, /127.0.0.1:51114 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-08 17:44:45.377 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=HGETALL, output=MapOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-08 17:44:45.377 DEBUG 53842 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=HGETALL, output=MapOutput [output={[B@1abf3922=[B@65bc29cc, [B@1c8803bf=[B@6a97a70, [B@3d43d690=[B@5a6014e1}, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-08 17:44:45.377 DEBUG 53842 --- [nio-8080-exec-5] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection

从日志中查看到,这个过程中发生 10 次 redis 操作,分别是:

HGETALL
HMSET
SREM
SADD
PEXPIRE
APPEND
PEXPIRE
PEXPIRE
HGETALL
HGETALL

在这个过程中,还有定时任务在维护这些 key ,分别是:

SMEMBERS
DEL
2019-07-09 17:41:00.004 DEBUG 65333 --- [pool-1-thread-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-09 17:41:00.004 DEBUG 65333 --- [pool-1-thread-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=SMEMBERS, output=ValueSetOutput [output=[], error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.004 DEBUG 65333 --- [pool-1-thread-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=SMEMBERS, output=ValueSetOutput [output=[], error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.004 DEBUG 65333 --- [pool-1-thread-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-09 17:41:00.004 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=SMEMBERS, output=ValueSetOutput [output=[], error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-09 17:41:00.004 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=SMEMBERS, output=ValueSetOutput [output=[], error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.006 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-09 17:41:00.006 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-09 17:41:00.006 DEBUG 65333 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=SMEMBERS, output=ValueSetOutput [output=[], error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.006 DEBUG 65333 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=SMEMBERS, output=ValueSetOutput [output=[], error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-09 17:41:00.006 DEBUG 65333 --- [pool-1-thread-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection
2019-07-09 17:41:00.006 DEBUG 65333 --- [pool-1-thread-1] o.s.d.redis.core.RedisConnectionUtils    : Opening RedisConnection
2019-07-09 17:41:00.007 DEBUG 65333 --- [pool-1-thread-1] io.lettuce.core.RedisChannelHandler      : dispatching command AsyncCommand [type=DEL, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.007 DEBUG 65333 --- [pool-1-thread-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=DEL, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.007 DEBUG 65333 --- [pool-1-thread-1] i.lettuce.core.protocol.DefaultEndpoint  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, epid=0x1] write() done
2019-07-09 17:41:00.007 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, chid=0x1] write(ctx, AsyncCommand [type=DEL, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-07-09 17:41:00.007 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandEncoder  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379] writing command AsyncCommand [type=DEL, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.008 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack
2019-07-09 17:41:00.008 DEBUG 65333 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler  : [channel=0xb74f9c60, /127.0.0.1:63921 -> localhost/127.0.0.1:6379, chid=0x1] Stack contains: 1 commands
2019-07-09 17:41:00.008 DEBUG 65333 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decode AsyncCommand [type=DEL, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-07-09 17:41:00.008 DEBUG 65333 --- [ioEventLoop-4-1] i.l.core.protocol.RedisStateMachine      : Decoded AsyncCommand [type=DEL, output=IntegerOutput [output=0, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true
2019-07-09 17:41:00.008 DEBUG 65333 --- [pool-1-thread-1] o.s.d.redis.core.RedisConnectionUtils    : Closing Redis Connection

这些 redis 的操作,主要就是维护上面看到那三个 key 的数据,具体每个 redis 操作到底是做了什么,在后面的再继续分析。

大概的底层源码是在 org.springframework.session.data.redis.RedisOperationsSessionRepository 中,在这里使用 RedisOperations 绑定 hash 操作,接着就可以去操作 redis 中的 session

private BoundHashOperations<Object, Object, Object> getSessionBoundHashOperations(
		String sessionId) {
	String key = getSessionKey(sessionId);
	return this.sessionRedisOperations.boundHashOps(key);
}

4. 结论

在使用 spring-session-data-redis 来管理 session 还是挺耗 redis 资源的,尤其是请求量非常大的时候,因此,如果对于应用服务是对 redis 服务要求很高的情况,最好考虑将 session 管理用一个单独的 redis 来处理,不要将其与业务的 redis 混在一起使用。


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值