matchJson.ts 865 字节
/**
 * Created by sunney on 7/3/17.
 */
import Model = require('../model');

import { cache,redis as client, redis, task_lock } from '../../../cache'

export async function getMatchJson({type,match}:any) {
  try {
    let match_team_info_key = `${config.CachePrefix}match:match_json:v1_${match.Id}_${type}`
    let t:any = await client.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
        }
      })
      client.set(match_team_info_key, t.Json)
      client.expire(match_team_info_key, 60*60*24)
    }
    if (t == null)
      return '{}'
    return t.Json;
  }catch (e:any){
    return '{}'
  }
}