原寫法:redis
@Autowired private RedisTemplate redisTemplate;
寫入redis後,查看key值post
127.0.0.1:6379> keys * 1) "\xac\xed\x00\x05t\x00#ContentPlatform2:ES:UpSertESContent" 2) "\xac\xed\x00\x05t\x00%ContentPlatform2:Lock_v16:CJH_ARTICLE" 3) "\xac\xed\x00\x05t\x00!ContentPlatform2:Lock_v16:V_VIDEO" 4) "\xac\xed\x00\x05t\x00\x1bContentPlatform2:ES:Content" 5) "\xac\xed\x00\x05t\x00#ContentPlatform2:Lock_v16:CJH_VIDEO" 6) "\xac\xed\x00\x05t\x00%ContentPlatform2:Lock_v16:CMS_ARTICLE"
解決方式:學習
private RedisTemplate redisTemplate; @Autowired(required = false) public void setRedisTemplate(RedisTemplate redisTemplate) { RedisSerializer stringSerializer = new StringRedisSerializer(); redisTemplate.setKeySerializer(stringSerializer); redisTemplate.setValueSerializer(stringSerializer); redisTemplate.setHashKeySerializer(stringSerializer); redisTemplate.setHashValueSerializer(stringSerializer); this.redisTemplate = redisTemplate; }
調整後查看redis key值:ui
127.0.0.1:6379> keys * 1) "ContentPlatform2:Lock_v17:V_VIDEO" 2) "ContentPlatform2:Lock_v17:CMS_ARTICLE" 3) "ContentPlatform2:ES:Content" 4) "ContentPlatform2:Lock_v17:CJH_ARTICLE」