Example #1
0
 /**
  * Test exists()
  *
  * @return void
  */
 public function testExists()
 {
     foreach ($this->screen_names as $sn) {
         try {
             $id = $this->Cache->sn2id($sn);
             $response = $this->Cache->exists($id);
             $this->assertTrue($response);
         } catch (Exception $e) {
             $this->assertInstanceOf(CacheException::class, $e);
         }
     }
 }
Example #2
0
 $user = filter_input(INPUT_GET, "user");
 if (!empty($user) && is_string($user)) {
     foreach (explode(",", $user) as $sn) {
         $filter[] = $sn;
     }
 }
 $user_ids = [];
 $names = [];
 $create_cache = [];
 foreach ($SaveTweet->tweetsList() as $row) {
     $user_ids[] = $row["user_id"];
 }
 if (count($user_ids) !== 0) {
     $statuses = $TwistOAuth->get("users/lookup", ["user_id" => implode(",", array_values(array_unique($user_ids)))]);
     foreach ($statuses as $status) {
         if ($Cache->exists($status->id_str)) {
             $json = json_decode(file_get_contents(config("cache.path") . "/{$status->id_str}/data.json"));
             $names[$status->id_str]["name"] = $json->name;
             $names[$status->id_str]["screen_name"] = $json->screen_name;
             $names[$status->id_str]["icon"] = $json->icon;
             continue;
         }
         $create_cache[] = $status->id_str;
         $names[$status->id_str] = ["name" => $status->name, "icon" => str_replace("_normal", "", $status->profile_image_url_https)];
     }
     foreach ($create_cache as $id) {
         if ($Cache->exists($id) && $Cache->update_at($id) >= 1) {
             $Cache->update($id);
         } else {
             $Cache->create($id);
         }