Skip to content

Commit

Permalink
something, something, default values
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin committed Dec 12, 2024
1 parent d380358 commit 5dc27df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/DataProviders/CachedHafas.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CachedHafas extends Hafas implements DataProviderInterface
{

public function fetchHafasTrip(string $tripID, string $lineName): Trip {
$key = CacheKey::getHafasTripKey($tripID);
$key = CacheKey::getHafasTripKey($tripID, $lineName);

return $this->remember($key, now()->addMinutes(15), function() use ($tripID, $lineName) {
return parent::fetchHafasTrip($tripID, $lineName);
Expand Down
7 changes: 4 additions & 3 deletions app/Helpers/CacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CacheKey
private const string LEADERBOARD_FRIENDS = 'LeaderboardFriends';
private const string LEADERBOARD_MONTH = 'LeaderboardMonth';
private const string STATISTICS_GLOBAL = 'StatisticsGlobal';
private const string HAFAS_TRIP = '_HafasTrip';
private const string HAFAS_TRIP = '_HafasTrip_%s_%s';
private const string HAFAS_STATIONS = '_HafasStations';
private const string HAFAS_DEPARTURES = '_HafasDepartures_%d_%s_%s';
private const string HAFAFS_STATION_RIL = '_HafasStationRil';
Expand All @@ -32,8 +32,9 @@ class CacheKey
private const string FOR = '%s-for-%s';
private const string FROM_TO = '%s-from-%s-to-%s';

public static function getHafasTripKey(string $tripId): string {
return sprintf(self::FOR, self::HAFAS_TRIP, $tripId);
public static function getHafasTripKey(string $tripId, string $lineName): string {
$tripId = sha1($tripId);
return sprintf(self::HAFAS_TRIP, $tripId, $lineName);
}

public static function getHafasStationsKey(string $query): string {
Expand Down
2 changes: 1 addition & 1 deletion config/trwl.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
'cache' => [
'global-statistics-retention-seconds' => env('GLOBAL_STATISTICS_CACHE_RETENTION_SECONDS', 60 * 60),
'leaderboard-retention-seconds' => env('LEADERBOARD_CACHE_RETENTION_SECONDS', 5 * 60),
'hafas' => env('HAFAS_CACHE', true),
'hafas' => env('HAFAS_CACHE', false),
],
'year_in_review' => [
'alert' => env('YEAR_IN_REVIEW_ALERT', false),
Expand Down

0 comments on commit 5dc27df

Please sign in to comment.