Esempio n. 1
0
 /**
  * 重建回复缓存.
  *
  * @param int $accountId 公众号ID
  */
 public function rebuildReplyCache($accountId)
 {
     $replies = $this->replyRepository->all($accountId);
     if (empty($replies)) {
         Cache::forget('replies_' . $accountId);
     }
     $caches = [];
     foreach ($replies as $reply) {
         foreach ($reply['trigger_keywords'] as $keyword) {
             $caches[$keyword]['type'] = $reply['trigger_type'];
             $caches[$keyword]['content'] = $reply['content'];
         }
     }
     Cache::forever('replies_' . $accountId, $caches);
 }