File tree Expand file tree Collapse file tree 4 files changed +96
-16
lines changed 
main/java/com/tistory/heowc/config 
test/java/com/tistory/heowc Expand file tree Collapse file tree 4 files changed +96
-16
lines changed Original file line number Diff line number Diff line change 1+ package  com .tistory .heowc .config ;
2+ 
3+ import  org .springframework .context .annotation .Bean ;
4+ import  org .springframework .context .annotation .Configuration ;
5+ import  org .springframework .data .redis .connection .jedis .JedisConnectionFactory ;
6+ import  org .springframework .data .redis .core .RedisTemplate ;
7+ import  org .springframework .data .redis .core .StringRedisTemplate ;
8+ 
9+ @ Configuration 
10+ public  class  RedisConfig  {
11+ 
12+     @ Bean 
13+     public  JedisConnectionFactory  jedisConnectionFactory () {
14+         return  new  JedisConnectionFactory ();
15+     }
16+ 
17+     @ Bean 
18+     public  RedisTemplate <String , String > redisTemplate () {
19+         RedisTemplate <String , String > template  =  new  RedisTemplate <>();
20+         template .setConnectionFactory (jedisConnectionFactory ());
21+         return  template ;
22+     }
23+ 
24+     @ Bean 
25+     public  StringRedisTemplate  stringRedisTemplate () {
26+         return  new  StringRedisTemplate (jedisConnectionFactory ());
27+     }
28+ }
Original file line number Diff line number Diff line change 1+ package  com .tistory .heowc ;
2+ 
3+ import  org .junit .FixMethodOrder ;
4+ import  org .junit .Test ;
5+ import  org .junit .runner .RunWith ;
6+ import  org .junit .runners .MethodSorters ;
7+ import  org .springframework .beans .factory .annotation .Autowired ;
8+ import  org .springframework .boot .test .context .SpringBootTest ;
9+ import  org .springframework .data .redis .core .RedisTemplate ;
10+ import  org .springframework .data .redis .core .ValueOperations ;
11+ import  org .springframework .test .context .junit4 .SpringRunner ;
12+ 
13+ import  javax .annotation .Resource ;
14+ 
15+ @ RunWith (SpringRunner .class )
16+ @ SpringBootTest 
17+ @ FixMethodOrder (value  = MethodSorters .NAME_ASCENDING )
18+ public  class  SimpleRedisTemplateTest  {
19+ 
20+ 	private  static  final  String  KEY  = "test_key" ;
21+ 
22+ 	@ Autowired 
23+ 	private  RedisTemplate <String , String > redisTemplate ;
24+ 	@ Resource (name  = "redisTemplate" )
25+ 	private  ValueOperations <String , String > listOps ;
26+ 
27+ 	@ Test 
28+ 	public  void  test1_push () throws  Exception  {
29+ 		listOps .set (KEY , "wonchul" );
30+ 	}
31+ 
32+ 	@ Test 
33+ 	public  void  test2_pop () throws  Exception  {
34+ 		System .out .println (String .format ("pop [ %s ]" , listOps .get (KEY )));
35+ 	}
36+ 
37+ }
Load Diff This file was deleted. 
Original file line number Diff line number Diff line change 1+ package  com .tistory .heowc ;
2+ 
3+ import  org .junit .FixMethodOrder ;
4+ import  org .junit .Test ;
5+ import  org .junit .runner .RunWith ;
6+ import  org .junit .runners .MethodSorters ;
7+ import  org .springframework .beans .factory .annotation .Autowired ;
8+ import  org .springframework .boot .test .context .SpringBootTest ;
9+ import  org .springframework .data .redis .core .StringRedisTemplate ;
10+ import  org .springframework .test .context .junit4 .SpringRunner ;
11+ 
12+ @ RunWith (SpringRunner .class )
13+ @ SpringBootTest 
14+ @ FixMethodOrder (value  = MethodSorters .NAME_ASCENDING )
15+ public  class  StringRedisTemplateTest  {
16+ 
17+ 	private  static  final  String  KEY  = "test_string" ;
18+ 
19+ 	@ Autowired  StringRedisTemplate  stringRedisTemplate ;
20+ 
21+ 	@ Test 
22+ 	public  void  test1_push () throws  Exception  {
23+ 		stringRedisTemplate .opsForValue ().set (KEY , "wonchul" );
24+ 	}
25+ 
26+ 	@ Test 
27+ 	public  void  test2_pop () throws  Exception  {
28+ 		System .out .println (String .format ("pop [ %s ]" , stringRedisTemplate .opsForValue ().get (KEY )));
29+ 	}
30+ 
31+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments