Method Introduction
1.sadd ()
Description: Adds a value to a key. If this value is already in this key, it returns false. Parameter: Key value return value: Successful return true, failed false
2.delete ()Description: Delete the specified key parameter: A key, or an indeterminate number of arguments, for each key array: Key1 key2 Key3 ... keyn return value: Number of items deleted
Private Function Getjsapiticket () {//==================author D xx start=================//1. Cache Wx Jsapiticket if (! $jsapiTicket = Cache::get (' Wxjsapiticket ')) {if (Cache::init ()->handler ()->sadd ( ' Wxjsapistorm ', ' 11 ') {//1.1 gets accesstoken $accessToken = $this->getaccesstoken (); 1.2 Request $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token= {$accessToken} "; $res = file_get_contents ($url); Trace ($res); $res = Json_decode ($res); $jsapiTicket = $res->ticket; if (Isset ($jsapiTicket)) {//Cache Cache::set (' Wxjsapiticket ', $jsapiTicket, 7000); }//Delete key Cache::init ()->handler ()->delete (' Wxjsapistorm '); } else {sleep (1); $this->getjsapiticket (); }} return $jsapiTicket; ==================author D xx end=================}
tp5.0 combined with Redis cache caching Storm