fix: invalidate booking data caches after updating personal data
This commit is contained in:
1 parent
8887b06583
commit
e5781fbabc
7 files changed
+62
-46
No files matched your search
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Booking\Traits;
|
||||
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Notification;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
|
||||
trait BookingDataTrait
|
||||
{
|
||||
public function fetchBookingData(string $email, string $password, int $id): Booking|Notification|null
|
||||
{
|
||||
$cacheKey = sprintf('bpn_booking_%d', $id);
|
||||
try {
|
||||
$bookingData = $this->cache->get($cacheKey, function (ItemInterface $item) use ($email, $password, $id) {
|
||||
$item->expiresAfter(300);
|
||||
|
||||
return $this->apiClient->getBooking($email, $password, $id);
|
||||
});
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$bookingData = null;
|
||||
}
|
||||
|
||||
return $bookingData;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user