package com.koobietech.eas.service.impl;

import com.koobietech.eas.common.service.RedisService;
import com.koobietech.eas.service.EasArcArchiveRedisService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @author lc
 */
@Service
public class EasArcArchiveRedisServiceImpl implements EasArcArchiveRedisService {
    @Resource
    private RedisService redisService;

    private final int ARCHIVE_EXPIRE_TIME = 60*3;

    @Override
    public void saveArchiveToken(String token, String filePath) {
        //将token和filePath存入redis，时间设置成三分钟
        redisService.set(token, filePath, ARCHIVE_EXPIRE_TIME);
    }

    @Override
    public String getFilePathByToken(String token) {
        // 如果取出的值为空，说明token已经过期，返回null
        // 如果取出的值不为空，说明token没有过期，返回v值
        return (String) redisService.get(token);
    }

}
