Created
July 12, 2018 13:29
-
-
Save briedis/dde909a5b95905d80b1ed4188ec9bad5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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