package com.qmth.themis.business.cache;

import com.qmth.themis.business.cache.bean.LivenessVerifyCacheBean;
import com.qmth.themis.business.constant.SpringContextHolder;
import com.qmth.themis.business.util.RedisUtil;

import java.util.Objects;

/**
 * 活检缓存
 *
 * @Description:
 * @Author: xiatian
 * @Date: 2020-08-11
 */
public class LivenessVerifyCacheUtil {
    private static RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);

    public static void setLivenessVerifyCacheBean(Long examRecordId, Long id, LivenessVerifyCacheBean bean) {
        redisUtil.set(RedisKeyHelper.livenessVerifyCacheKey(examRecordId), id.toString(), bean);
    }

    public static LivenessVerifyCacheBean getLivenessVerifyCacheBean(Long examRecordId, Long id) {
        return Objects.nonNull(redisUtil.get(RedisKeyHelper.livenessVerifyCacheKey(examRecordId), id.toString())) ? (LivenessVerifyCacheBean) redisUtil.get(RedisKeyHelper.livenessVerifyCacheKey(examRecordId), id.toString()) : null;
    }
}
