package com.qmth.themis.business.cache;

import com.qmth.themis.business.cache.bean.FaceVerifyCacheBean;
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 FaceVerifyCacheUtil {
    private static RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);

    public static void setFaceVerifyCacheBean(Long examRecordId, Long id, FaceVerifyCacheBean bean) {
        redisUtil.set(RedisKeyHelper.faceVerifyCacheKey(examRecordId), id.toString(), bean);
    }

    public static FaceVerifyCacheBean getFaceVerifyCacheBean(Long examRecordId, Long id) {
        return Objects.nonNull(redisUtil.get(RedisKeyHelper.faceVerifyCacheKey(examRecordId), id.toString())) ? (FaceVerifyCacheBean) redisUtil.get(RedisKeyHelper.faceVerifyCacheKey(examRecordId), id.toString()) : null;
    }
}
