const CacheBase=require("../cache.base");
const system=require("../../system");
var settings=require("../../../config/settings");
const wxFunc=require("../../service/wxsvr");
/**
 * 微信开放平台 component_verify_ticket协议
 */
class WxcomponentverifyticketCache extends CacheBase{
   constructor(){
     super();
     this.prefix="wx_component_verify_ticket_";
     this.restClient=system.getObject("util.restClient");
     this.wxopenplatformconfig = settings.wxopenplatformconfig;
   }
   async cacheComponentVerifyTicket(value){
        var key=this.prefix+this.wxopenplatformconfig.appid;
        if(value){
            var beforevalue = await this.redisClient.get(key);
            if(beforevalue!=value){
              await this.redisClient.set(key,value);
            }
            return value;
        }else{
            var value = await this.redisClient.get(key);
            return value;
        }
   }
}
module.exports=WxcomponentverifyticketCache;
//  var task = new WxcomponentverifyticketCache();

//  task.redisClient.set("wx_component_verify_ticket_wx8b0bf3ca5ea2d540","ticket@@@2SG-NONHrErt3gU4_lpFBbJqT9ucMJbT76QjLSlWsrOz0kHcZJlFp3G6aSRdG7v1QGTV06F3pDh59EElNUfjQA");

