Helius
2021-04-08 6a901e8b1b840f23a80604fe7851e2edf098c015
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.xcong.excoin;
 
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author wzy
 * @date 2020-07-15
 **/
@Slf4j
@SpringBootTest
public class RedisTest {
 
    @Resource
    private MemberDao memberDao;
 
    @Resource
    private RedisUtils redisUtils;
 
    @Test
    public void redisResetTest() {
        MemberEntity member = memberDao.selectById(72L);
        member.setPassword(new BCryptPasswordEncoder().encode(member.getPassword()));
        redisUtils.set("app_21c8fb68f5de4bbfb91a03813833db8a", JSONObject.toJSONString(member), 36000);
    }
 
    @Test
    public void redisObjectTest() {
        List<Object> aa = new ArrayList<>();
//        List<Object> test_list = redisUtils.lGet("test_list", 0, -1);
        aa.add(13L);
        Long id = 13L;
//        test_list.add(id);
        redisUtils.lSet("test_list", aa);
 
        List<Object> test_list1 = redisUtils.lGet("test_list", 0, -1);
        log.info("--->{}", test_list1);
        System.out.println(test_list1.contains(id.intValue()));
    }
 
}