package com.pannk.demo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.types.RedisClientInfo; import java.util.List; /** * Created by wolf on 20-11-13. */ @Slf4j @SpringBootApplication public class App implements CommandLineRunner{ @Autowired private RedisTemplate redisTemplate; public static void main(String[] args) { SpringApplication.run(App.class,args); } @Override public void run(String... args) throws Exception { /*redisTemplate.opsForValue().set("hello","Hello world redis"); String hello = (String) redisTemplate.opsForValue().get("hello"); List clientList = redisTemplate.getClientList(); clientList.stream().forEach(info->{ log.error("info:{}",info); }); log.error("=========hello:{}",hello); */ for (int i = 0; i < 1000; i++) { new Thread(() -> redisTemplate.opsForValue().set("key"+Thread.currentThread().getName(),"The value is "+Thread.currentThread().getId())).start(); } } }