chore: streamline property naming
This commit is contained in:
@@ -511,6 +511,39 @@ class TravelDataService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch availability data with short-term caching.
|
||||
*
|
||||
* Retrieves availability information from the API with caching to reduce
|
||||
* API calls during booking form interactions. Uses a short TTL to ensure
|
||||
* reasonably fresh data while avoiding excessive API requests.
|
||||
*
|
||||
* @param int $dateId The travel date ID for API call
|
||||
* @param int $ttl Cache TTL in seconds (default: 60 seconds)
|
||||
*
|
||||
* @return BaseData|null The availability data or null if not available or error occurred
|
||||
*/
|
||||
public function getAvailabilityDataCached(int $dateId, int $ttl = 60): ?BaseData
|
||||
{
|
||||
$cacheKey = sprintf('availability_%d', $dateId);
|
||||
|
||||
try {
|
||||
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($dateId, $ttl) {
|
||||
$item->expiresAfter($ttl);
|
||||
|
||||
return $this->getAvailabilityData($dateId);
|
||||
});
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->logger->error('Cache error in getAvailabilityDataCached', [
|
||||
'dateId' => $dateId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
// Fallback to direct API call
|
||||
return $this->getAvailabilityData($dateId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply availability data to travel services.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user