fix: reduce mutability data cache ttl to avoid staleness
addresses #869cdzmkq
This commit is contained in:
@@ -31,10 +31,10 @@ use Symfony\Contracts\Cache\ItemInterface;
|
|||||||
*/
|
*/
|
||||||
class TravelDataService
|
class TravelDataService
|
||||||
{
|
{
|
||||||
public const SOURCE_LOCAL = 'local';
|
public const string SOURCE_LOCAL = 'local';
|
||||||
public const SOURCE_REMOTE = 'remote';
|
public const string SOURCE_REMOTE = 'remote';
|
||||||
private const AVAILABILITY_CACHE_TTL = 600;
|
private const int AVAILABILITY_CACHE_TTL = 600;
|
||||||
private const MUTABILITY_CACHE_TTL = 3600;
|
private const int MUTABILITY_CACHE_TTL = 300;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TravelLoader $travelLoader,
|
private readonly TravelLoader $travelLoader,
|
||||||
@@ -440,7 +440,7 @@ class TravelDataService
|
|||||||
* Gets mutability data for a travel date.
|
* Gets mutability data for a travel date.
|
||||||
*
|
*
|
||||||
* @param int $dateId The travel date ID for API call
|
* @param int $dateId The travel date ID for API call
|
||||||
* @param bool $cached Whether to use cached data (default: true, TTL: 1 hour)
|
* @param bool $cached Whether to use cached data (default: true, TTL: 5 minutes)
|
||||||
* @param bool $forceRefresh Whether to invalidate cache before fetching (requires cached: true)
|
* @param bool $forceRefresh Whether to invalidate cache before fetching (requires cached: true)
|
||||||
*
|
*
|
||||||
* @return BaseData|null The mutability data or null if not available or error occurred
|
* @return BaseData|null The mutability data or null if not available or error occurred
|
||||||
@@ -456,7 +456,6 @@ class TravelDataService
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($dateId) {
|
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($dateId) {
|
||||||
// 1 hour TTL - better safe than sorry with mutability changes
|
|
||||||
$item->expiresAfter(self::MUTABILITY_CACHE_TTL);
|
$item->expiresAfter(self::MUTABILITY_CACHE_TTL);
|
||||||
|
|
||||||
return $this->fetchMutabilityData($dateId);
|
return $this->fetchMutabilityData($dateId);
|
||||||
|
|||||||
Reference in New Issue
Block a user