Skip to content

Instantly share code, notes, and snippets.

@chadtomkiss
Last active August 15, 2016 16:18
Show Gist options
  • Save chadtomkiss/52ef04cd2e606f32a1357e9d27050430 to your computer and use it in GitHub Desktop.
Save chadtomkiss/52ef04cd2e606f32a1357e9d27050430 to your computer and use it in GitHub Desktop.
Caching API Shit
<?php
use Illuminate\Contracts\Cache\Repository as CacheRepository;
class ApiCache
{
public function __construct(CacheRepository $cache, Api $api)
{
$this->cache = $cache;
$this->api = $api;
}
public function users()
{
$this->cache->remember('users', 90, function() {
return $this->api->users();
});
}
}
class Api
{
public function users()
{
// Guzzle HTTP request
// blah blah
return $users;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment