public function delete($key) { $keys_dict = $this->keys_dict(); if (isset($keys_dict[$key])) { unset($keys_dict[$key]); apcstore($this->keys_key(), $keys_dict); } apcdelete($this->value_key($key)); }
function profile_record_lock_time($lock_time) { $lc = apcfetch("LOCKTIME"); if ($lc !== FALSE) { $lc[0] += $lock_time; $lc[1] += 1; } else { $lc = array($lock_time, 1); } apcstore("LOCKTIME", $lc); }
private function control() { if ($this->control !== NULL) { return $this->control; } $v = apcfetch($this->ctrlkey()); if ($v === FALSE) { $v = new ApcListControl(); apcstore($this->ctrlkey(), $v); } $this->control = $v; return $v; }
private function getAccessToken() { // access_token 应该全局存储与更新,以下代码以写入到文件中做示例 $data = json_decode(file_get_contents("access_token.json")); if ($data->expire_time < time()) { // 如果是企业号用以下URL获取access_token // $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret"; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appId}&secret={$this->appSecret}"; $res = json_decode($this->httpGet($url)); $access_token = $res->access_token; if ($access_token) { $data->expire_time = time() + 7000; $data->access_token = $access_token; $fp = fopen("access_token.json", "w"); fwrite($fp, json_encode($data)); fclose($fp); apcstore("ACCESS_TOKEN", $data); } } else { $access_token = $data->access_token; } return $access_token; }
function on_apc_miss() { $rec = apcfetch("APC_HIT_RATE"); if ($rec == FALSE) { $rec = 0.0; } $rec = $rec * 0.99; apcstore("APC_HIT_RATE", $rec); }