Skip to content

Commit

Permalink
refactor githubApiProxy method
Browse files Browse the repository at this point in the history
  • Loading branch information
lifesign committed Mar 31, 2015
1 parent 67228bf commit 0ff7791
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions app/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,11 @@ public function githubApiProxy($username)
{
$cache_name = 'github_api_proxy_user_'.$username;

if (Cache::has($cache_name)) {
return Response::json(Cache::get($cache_name));
}

$result = (new GithubUserDataReader())->getDataFromUserName($username);

//Cache 1 day
Cache::put($cache_name, $result, 1440);

return Response::json($result);
return Cache::remember($cache_name, 1440, function () use ($username) {
$result = (new GithubUserDataReader())->getDataFromUserName($username);
return Response::json($result);
});
}

public function githubCard()
Expand Down

0 comments on commit 0ff7791

Please sign in to comment.