content: package com.jerry.poetry;
  
  import com.jerry.poetry.config.redis.RedisHelperImpl;
  import com.jerry.poetry.domain.Author;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.context.SpringBootTest;
  import org.springframework.data.redis.core.RedisTemplate;
  import org.springframework.data.redis.core.StringRedisTemplate;
  import org.springframework.data.redis.core.ValueOperations;
  import org.springframework.test.context.junit4.SpringRunner;
  
  import java.util.concurrent.TimeUnit;
  
  @RunWith(SpringRunner.class)
  @SpringBootTest
  public class TestRedis {
  
      @Autowired
      private StringRedisTemplate stringRedisTemplate;
  
      @Autowired
      private RedisTemplate redisTemplate;
  
      @Autowired
      private RedisHelperImpl redisHelper;
  
      @Test
      public void test() throws Exception{
  //        stringRedisTemplate.opsForValue().set("aaa","111");
  //        Assert.assertEquals("111",stringRedisTemplate.opsForValue().get("aaa"));
  //        System.out.println(stringRedisTemplate.opsForValue().get("aaa"));
          Author user=new Author();
          user.setName("Alex");
          user.setIntro_l("不会打篮球的程序不是好男人");
          redisHelper.valuePut("aaa",user);
          System.out.println(redisHelper.getValue("aaa"));
      }
  
      @Test
      public void testObj() throws Exception {
          Author user=new Author();
          user.setName("Jerry");
          user.setIntro_l("不会打篮球的程序不是好男人!");
  
          ValueOperations<String, Author> operations=redisTemplate.opsForValue();
          operations.set("com.neox", user);
          operations.set("com.neo.f", user,1,TimeUnit.SECONDS);
          Thread.sleep(1000);
          //redisTemplate.delete("com.neo.f");
          boolean exists=redisTemplate.hasKey("com.neox");
          if(exists){
              System.out.println(redisTemplate.opsForValue().get("com.neox"));
          }else{
              System.out.println("exists is false");
          }
          // Assert.assertEquals("aa", operations.get("com.neo.f").getUserName());
      }
  }
  