Skip to content

Instantly share code, notes, and snippets.

@briedis
Created July 12, 2018 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briedis/dde909a5b95905d80b1ed4188ec9bad5 to your computer and use it in GitHub Desktop.
Save briedis/dde909a5b95905d80b1ed4188ec9bad5 to your computer and use it in GitHub Desktop.
class AwesomeWrongApiWrapper
{
const COMPANIES = [
//
];
private function invalidate()
{
foreach (self::COMPANIES as $companyId) {
Cache::forget($this->getPositionKey($companyId));
}
}
public function getPositions($companyId)
{
$key = $this->getPositionKey($companyId);
$cached = Cache::get($key);
if ($cached) {
return $cached;
}
$response = $this->api->get('..');
Cache::put($key, $response);
return $response;
}
private function getPositionKey($companyId): string
{
return 'positions:' . $companyId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment