使用 springboot-data-redis.1.5.21 版本中,自定义keyGenerator,使用 @Cacheable 进行缓存, redis 缓存采用 zset 结构进行存储,如图:
通过全文搜索,大概知道 ~key 添加的地方
RedisCacheMetadata 是 RedisCache 的内部类,创建过程发生在 RedisCache 构造方法中:
而 RedisCache 是在 RedisCacheManager 中创建的:
可以看到第二个参数 usePrefix 决定了 key 是否已 ~key 后缀结尾,在 RedisConfig 中采用如下方法进行调试:
于是 key 就以 string 进行存储。