feat: load availability data once per booking session

This commit is contained in:
Björn Fromme
2026-03-16 12:00:56 +01:00
parent 8f542ff448
commit 12b69bd681
5 changed files with 11 additions and 12 deletions
+3 -4
View File
@@ -523,19 +523,18 @@ class TravelDataService
* Gets availability data for a travel date.
*
* @param int $dateId The travel date ID for API call
* @param bool $cached Whether to use cached data (default: false, TTL when cached: 300 seconds)
* @param int $ttl Cache TTL in seconds when $cached is true (default: 300 seconds)
* @param bool $cached Whether to use cached data (default: false, TTL when cached: 600 seconds)
* @param int $ttl Cache TTL in seconds when $cached is true (default: 600 seconds)
*
* @return ServiceAvailabilityResponse|null The availability data or null if not available or error occurred
*/
public function getAvailabilityData(int $dateId, bool $cached = false, int $ttl = 300): ?ServiceAvailabilityResponse
public function getAvailabilityData(int $dateId, bool $cached = false, int $ttl = 600): ?ServiceAvailabilityResponse
{
if ($cached) {
$cacheKey = sprintf('availability_%d', $dateId);
try {
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($dateId, $ttl) {
// Short TTL - availability is volatile and changes with bookings
$item->expiresAfter($ttl);
return $this->fetchAvailabilityData($dateId);