matchJson.js 1.1 KB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMatchJson = void 0;
/**
 * Created by sunney on 7/3/17.
 */
const Model = require("../model");
const cache_1 = require("../../../cache");
async function getMatchJson({ type, match }) {
    try {
        let match_team_info_key = `${config.CachePrefix}match:match_json:v1_${match.Id}_${type}`;
        let t = await cache_1.redis.get(match_team_info_key);
        if (t && t.length > 0 && !match.isUpdateCache) {
            return t;
        }
        else {
            t = await Model.MatchJson.findOne({
                where: {
                    Type: type,
                    LotteryId: match.LotteryId,
                    IssueName: match.IssueName,
                    MatchNumber: match.MatchNumber
                }
            });
            cache_1.redis.set(match_team_info_key, t.Json);
            cache_1.redis.expire(match_team_info_key, 60 * 60 * 24);
        }
        if (t == null)
            return '{}';
        return t.Json;
    }
    catch (e) {
        return '{}';
    }
}
exports.getMatchJson = getMatchJson;
//# sourceMappingURL=matchJson.js.map