RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setHostName("localhost");
redisStandaloneConfiguration.setPort(6379);
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration);
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(jedisConnectionFactory);
// 这行代码有点意思啊。
redisTemplate.afterPropertiesSet();
System.out.println(redisTemplate.keys("key1"));
System.out.println(redisTemplate.hasKey("key"));
System.out.println(redisTemplate.opsForValue().get("key"));
redisTemplate.opsForValue().set("key","hahah");
redisTemplate.delete("key");
ArrayList<Object> objects = new ArrayList<>();
objects.add("hhello owrld");
redisTemplate.opsForList().leftPushAll("key",objects);
redisTemplate.opsForList().leftPop("key",1000L, TimeUnit.NANOSECONDS );
System.out.println(redisTemplate.opsForValue().get("key"));
StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
stringRedisTemplate.setConnectionFactory(jedisConnectionFactory);
stringRedisTemplate.afterPropertiesSet();
System.out.println(stringRedisTemplate.hasKey("key"));
网友评论