Recently I have been using spring-boot-starter-data-redis;
I use spring-boot-version:2.3.8.RELEASE;
application.yml
spring: redis: cluster: nodes: - 10.253.48.212:6379 - 10.253.48.212:6380 - 10.253.48.213:6379 - 10.253.48.213:6380 - 10.253.48.214:6379 - 10.253.48.214:6380
I set up Redis-Cluster according to the article; https://redis.io/topics/cluster-tutorial
The setup process was also recorded in additor;although the notes were in Chinese;
I follow the article spring-data-redis to use Redis-Client;
I wrote the code based on the [10.6. Working with Objects through RedisTemplate];
But there was a problem with redisTemplate and stringRedisTemplate;
@RunWith(SpringRunner.class) @SpringBootTest(classes = {RedisApp.class}) public class RedisTest { @Resource(name="stringRedisTemplate") private ValueOperations<String, String> stringValueOperations; @Resource(name="redisTemplate") private ValueOperations<String, String> valueOperations; @Test public void test() { stringValueOperations.set("name", "yufr-bigName"); valueOperations.set("name", "yufr"); System.out.println(stringValueOperations.get("name")); System.out.println(valueOperations.get("name")); } }
result in idea-console:
yufr-bigName yufr
result in redis-cluster-server:
10.253.48.214:6379> get name "yufr-bigName"
why redisTemplate set-command does not work?
Anonymous Asked question May 14, 2021
Recent Comments