package com.seamew.lottery.test.infrastructure;

import com.seamew.lottery.domain.activity.model.req.PartakeReq;
import com.seamew.lottery.domain.activity.service.partake.IActivityPartake;
import com.seamew.lottery.infrastructure.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * @Author: seamew
 * @Title: RedisUtilTest
 * @CreateTime: 2023年03月03日 10:50:00
 * @Description: Redis 使用测试
 * @Version: 1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class RedisUtilTest {
    @Resource
    private IActivityPartake activityPartake;
    @Resource
    private RedisUtil redisUtil;

    @Test
    public void test_set() {
        PartakeReq partakeReq = new PartakeReq("xiaofuge", 100001L);
        activityPartake.doPartake(partakeReq);
    }

    @Test
    public void test_get() {
        // redisUtil.set("test", 0);
        // String test = redisUtil.get("test");
        // System.out.println(test);
        redisUtil.setNx("key", 100000L);
        redisUtil.expire("key", 5);
    }
}
